/* * Callback for bsd_stream_read_sync */ static void stream_read_sync_callback( void * s) { struct sec_stream *bs = s; ssize_t n; assert(bs != NULL); auth_debug(1, _("bsd: stream_read_callback_sync: fd %d\n"), bs->fd); /* * Remove the event first, in case they reschedule it in the callback. */ bsd_stream_read_cancel(bs); do { n = read(bs->fd, bs->databuf, sizeof(bs->databuf)); } while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN))); if (n < 0) security_stream_seterror(&bs->secstr, "%s", strerror(errno)); bs->len = n; sync_pktlen = bs->len; sync_pkt = malloc(sync_pktlen); memcpy(sync_pkt, bs->databuf, sync_pktlen); }
/* * Close and unallocate resources for a stream */ static void bsd_stream_close( void * s) { struct sec_stream *bs = s; assert(bs != NULL); if (bs->fd != -1) aclose(bs->fd); if (bs->socket != -1) aclose(bs->socket); bsd_stream_read_cancel(bs); amfree(bs); }
/* * Callback for bsd_stream_read */ static void stream_read_callback( void * arg) { struct sec_stream *bs = arg; ssize_t n; assert(bs != NULL); do { n = read(bs->fd, bs->databuf, sizeof(bs->databuf)); } while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN))); if (n <= 0) bsd_stream_read_cancel(bs); if (n < 0) security_stream_seterror(&bs->secstr, "%s", strerror(errno)); (*bs->fn)(bs->arg, bs->databuf, n); }
/* * Callback for bsd_stream_read */ static void stream_read_callback( void * arg) { struct sec_stream *bs = arg; ssize_t n; assert(bs != NULL); /* * Remove the event first, in case they reschedule it in the callback. */ bsd_stream_read_cancel(bs); do { n = read(bs->fd, bs->databuf, sizeof(bs->databuf)); } while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN))); if (n < 0) security_stream_seterror(&bs->secstr, "%s", strerror(errno)); (*bs->fn)(bs->arg, bs->databuf, n); }