169
iphb_wait(iphb_t iphbh, unsigned short mintime, unsigned short maxtime, int must_wait)
169
iphb_wait2(iphb_t iphbh, unsigned mintime, unsigned maxtime, int must_wait, int resume)
171
171
struct _iphb_req_t req = {IPHB_WAIT};
172
172
struct _iphb_wait_resp_t resp = {0};
179
179
(void)suck_data(HB_INST(iphbh)->fd);
181
req.u.wait.mintime = mintime;
182
req.u.wait.maxtime = maxtime;
183
req.u.wait.pid = getpid();
181
/* There are apps that contain out of date libiphb versions built
182
* in to the application binaries and we need to at least attempt
183
* not to break handling of iphb requests that used to be ok.
185
* Originally the version field did not exist, but the area now
186
* occupied by it was initialized to zero. By setting it now to
187
* a non-zero value, we can signal the server side that additional
190
* Version 1 adds: mintime_hi, maxtime_hi and wakeup fields
192
req.u.wait.version = 1;
194
/* Originally mintime and maxtime were 16 bits wide. As we must
195
* keep the structure layout compatible with it, the extension
196
* to 32bit range is done by having upper halfs stored separately.
197
* The Server side ignores upper parts unless version >= 1. */
198
req.u.wait.mintime = (mintime >> 0) & 0xffff;
199
req.u.wait.mintime_hi = (mintime >> 16) & 0xffff;
200
req.u.wait.maxtime = (maxtime >> 0) & 0xffff;
201
req.u.wait.maxtime_hi = (maxtime >> 16) & 0xffff;
203
/* Client process id */
204
req.u.wait.pid = getpid();
206
/* The server side ignores this unless version >= 1 */
207
req.u.wait.wakeup = (resume != 0);
185
209
if (send(HB_INST(iphbh)->fd, &req, sizeof(req), MSG_DONTWAIT|MSG_NOSIGNAL) <= 0)
189
213
return (time_t)0;
224
248
return (time_t)-1;
252
iphb_wait(iphb_t iphbh, unsigned short mintime, unsigned short maxtime, int must_wait)
254
return iphb_wait2(iphbh, mintime, maxtime, must_wait, 1);
229
259
iphb_discard_wakeups(iphb_t iphbh)