Deleted Added
full compact
mevent_test.c (330449) mevent_test.c (336161)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2011 NetApp, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2011 NetApp, Inc.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 11 unchanged lines hidden (view full) ---

20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: stable/11/usr.sbin/bhyve/mevent_test.c 330449 2018-03-05 07:26:05Z eadler $
28 * $FreeBSD: stable/11/usr.sbin/bhyve/mevent_test.c 336161 2018-07-10 04:26:32Z araujo $
29 */
30
31/*
32 * Test program for the micro event library. Set up a simple TCP echo
33 * service.
34 *
35 * cc mevent_test.c mevent.c -lpthread
36 */

--- 157 unchanged lines hidden (view full) ---

194acceptor(void *param)
195{
196 struct sockaddr_in sin;
197 pthread_t tid;
198 int news;
199 int s;
200 static int first;
201
29 */
30
31/*
32 * Test program for the micro event library. Set up a simple TCP echo
33 * service.
34 *
35 * cc mevent_test.c mevent.c -lpthread
36 */

--- 157 unchanged lines hidden (view full) ---

194acceptor(void *param)
195{
196 struct sockaddr_in sin;
197 pthread_t tid;
198 int news;
199 int s;
200 static int first;
201
202 if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
203 perror("socket");
204 exit(1);
205 }
202 if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
203 perror("socket");
204 exit(1);
205 }
206
206
207 sin.sin_len = sizeof(sin);
208 sin.sin_family = AF_INET;
209 sin.sin_addr.s_addr = htonl(INADDR_ANY);
210 sin.sin_port = htons(TEST_PORT);
207 sin.sin_len = sizeof(sin);
208 sin.sin_family = AF_INET;
209 sin.sin_addr.s_addr = htonl(INADDR_ANY);
210 sin.sin_port = htons(TEST_PORT);
211
211
212 if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
213 perror("bind");
214 exit(1);
215 }
212 if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
213 perror("bind");
214 exit(1);
215 }
216
216
217 if (listen(s, 1) < 0) {
218 perror("listen");
219 exit(1);
220 }
217 if (listen(s, 1) < 0) {
218 perror("listen");
219 exit(1);
220 }
221
222 (void) mevent_add(s, EVF_READ, acceptor_callback, NULL);
223
224 pthread_mutex_lock(&accept_mutex);
225
226 while (!pthread_cond_wait(&accept_condvar, &accept_mutex)) {
227 news = accept(s, NULL, NULL);
228 if (news < 0) {

--- 30 unchanged lines hidden ---
221
222 (void) mevent_add(s, EVF_READ, acceptor_callback, NULL);
223
224 pthread_mutex_lock(&accept_mutex);
225
226 while (!pthread_cond_wait(&accept_condvar, &accept_mutex)) {
227 news = accept(s, NULL, NULL);
228 if (news < 0) {

--- 30 unchanged lines hidden ---