| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: rumpclient.c,v 1.61 2014/04/03 17:11:35 pooka Exp $ */ | | 1 | /* $NetBSD: rumpclient.c,v 1.62 2014/04/25 12:20:12 pooka Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. | | 4 | * Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -40,27 +40,27 @@ | | | @@ -40,27 +40,27 @@ |
40 | * that lock may cause a deadlock. Therefore, block signals throughout | | 40 | * that lock may cause a deadlock. Therefore, block signals throughout |
41 | * the RPC when using poll. On Linux, we use signalfd in the same role | | 41 | * the RPC when using poll. On Linux, we use signalfd in the same role |
42 | * as kqueue on NetBSD to be able to take signals while waiting for a | | 42 | * as kqueue on NetBSD to be able to take signals while waiting for a |
43 | * response from the server. | | 43 | * response from the server. |
44 | */ | | 44 | */ |
45 | | | 45 | |
46 | #ifdef __NetBSD__ | | 46 | #ifdef __NetBSD__ |
47 | #define USE_KQUEUE | | 47 | #define USE_KQUEUE |
48 | #endif | | 48 | #endif |
49 | #if defined(__linux__) && !defined(__ANDROID__) | | 49 | #if defined(__linux__) && !defined(__ANDROID__) |
50 | #define USE_SIGNALFD | | 50 | #define USE_SIGNALFD |
51 | #endif | | 51 | #endif |
52 | | | 52 | |
53 | __RCSID("$NetBSD: rumpclient.c,v 1.61 2014/04/03 17:11:35 pooka Exp $"); | | 53 | __RCSID("$NetBSD: rumpclient.c,v 1.62 2014/04/25 12:20:12 pooka Exp $"); |
54 | | | 54 | |
55 | #include <sys/param.h> | | 55 | #include <sys/param.h> |
56 | #include <sys/mman.h> | | 56 | #include <sys/mman.h> |
57 | #include <sys/socket.h> | | 57 | #include <sys/socket.h> |
58 | #include <sys/time.h> | | 58 | #include <sys/time.h> |
59 | | | 59 | |
60 | #ifdef USE_KQUEUE | | 60 | #ifdef USE_KQUEUE |
61 | #include <sys/event.h> | | 61 | #include <sys/event.h> |
62 | #endif | | 62 | #endif |
63 | | | 63 | |
64 | #include <arpa/inet.h> | | 64 | #include <arpa/inet.h> |
65 | #include <netinet/in.h> | | 65 | #include <netinet/in.h> |
66 | #include <netinet/tcp.h> | | 66 | #include <netinet/tcp.h> |
| @@ -282,27 +282,27 @@ cliwaitresp(struct spclient *spc, struct | | | @@ -282,27 +282,27 @@ cliwaitresp(struct spclient *spc, struct |
282 | * ok, activity. try to read a frame to | | 282 | * ok, activity. try to read a frame to |
283 | * determine what happens next. | | 283 | * determine what happens next. |
284 | */ | | 284 | */ |
285 | activity: | | 285 | activity: |
286 | #else /* !USE_KQUEUE */ | | 286 | #else /* !USE_KQUEUE */ |
287 | struct pollfd pfd[2]; | | 287 | struct pollfd pfd[2]; |
288 | | | 288 | |
289 | pfd[0].fd = clispc.spc_fd; | | 289 | pfd[0].fd = clispc.spc_fd; |
290 | pfd[0].events = POLLIN; | | 290 | pfd[0].events = POLLIN; |
291 | pfd[1].fd = holyfd; | | 291 | pfd[1].fd = holyfd; |
292 | pfd[1].events = POLLIN; | | 292 | pfd[1].events = POLLIN; |
293 | | | 293 | |
294 | rv = host_poll(pfd, 2, -1); | | 294 | rv = host_poll(pfd, 2, -1); |
295 | if (pfd[1].revents & POLLIN) { | | 295 | if (rv >= 1 && pfd[1].revents & POLLIN) { |
296 | dosig = 1; | | 296 | dosig = 1; |
297 | goto cleanup; | | 297 | goto cleanup; |
298 | } | | 298 | } |
299 | #endif /* !USE_KQUEUE */ | | 299 | #endif /* !USE_KQUEUE */ |
300 | | | 300 | |
301 | switch (readframe(spc)) { | | 301 | switch (readframe(spc)) { |
302 | case 0: | | 302 | case 0: |
303 | continue; | | 303 | continue; |
304 | case -1: | | 304 | case -1: |
305 | imalive = false; | | 305 | imalive = false; |
306 | goto cleanup; | | 306 | goto cleanup; |
307 | default: | | 307 | default: |
308 | /* case 1 */ | | 308 | /* case 1 */ |