39 |
|
|
40 |
|
#define READBUF_SIZE 16384 |
41 |
|
|
42 |
– |
struct Callback *iorecv_cb = NULL; |
43 |
– |
|
42 |
|
static char readBuf[READBUF_SIZE]; |
43 |
|
static void client_dopacket(struct Client *, char *, size_t); |
44 |
|
|
269 |
|
} |
270 |
|
|
271 |
|
/* |
274 |
– |
* iorecv_default - append a packet to the recvq dbuf |
275 |
– |
*/ |
276 |
– |
void * |
277 |
– |
iorecv_default(va_list args) |
278 |
– |
{ |
279 |
– |
struct Client *client_p = va_arg(args, struct Client *); |
280 |
– |
int length = va_arg(args, int); |
281 |
– |
char *buf = va_arg(args, char *); |
282 |
– |
|
283 |
– |
dbuf_put(&client_p->localClient->buf_recvq, buf, length); |
284 |
– |
return NULL; |
285 |
– |
} |
286 |
– |
|
287 |
– |
/* |
272 |
|
* read_packet - Read a 'packet' of data from a connection and process it. |
273 |
|
*/ |
274 |
|
void |
294 |
|
/* translate openssl error codes, sigh */ |
295 |
|
if (length < 0) |
296 |
|
switch (SSL_get_error(fd->ssl, length)) |
297 |
< |
{ |
297 |
> |
{ |
298 |
|
case SSL_ERROR_WANT_WRITE: |
299 |
< |
fd->flags.pending_read = 1; |
300 |
< |
SetSendqBlocked(client_p); |
301 |
< |
comm_setselect(fd, COMM_SELECT_WRITE, (PF *) sendq_unblocked, |
302 |
< |
client_p, 0); |
319 |
< |
return; |
320 |
< |
case SSL_ERROR_WANT_READ: |
321 |
< |
errno = EWOULDBLOCK; |
299 |
> |
comm_setselect(fd, COMM_SELECT_WRITE, (PF *)sendq_unblocked, client_p, 0); |
300 |
> |
return; |
301 |
> |
case SSL_ERROR_WANT_READ: |
302 |
> |
errno = EWOULDBLOCK; |
303 |
|
case SSL_ERROR_SYSCALL: |
304 |
< |
break; |
304 |
> |
break; |
305 |
|
case SSL_ERROR_SSL: |
306 |
|
if (errno == EAGAIN) |
307 |
|
break; |
308 |
|
default: |
309 |
< |
length = errno = 0; |
310 |
< |
} |
309 |
> |
length = errno = 0; |
310 |
> |
} |
311 |
|
} |
312 |
|
else |
313 |
|
#endif |
328 |
|
return; |
329 |
|
} |
330 |
|
|
331 |
< |
execute_callback(iorecv_cb, client_p, length, readBuf); |
331 |
> |
dbuf_put(&client_p->localClient->buf_recvq, readBuf, length); |
332 |
|
|
333 |
|
if (client_p->localClient->lasttime < CurrentTime) |
334 |
|
client_p->localClient->lasttime = CurrentTime; |