diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2006-11-26 15:22:59 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2006-11-26 15:22:59 +0000 |
commit | cbb9db8873092c40a728e0347abf1d619ebf1101 (patch) | |
tree | f440befde2402d683f0e9166909a3d9ce0ebd81e /lib/libevent | |
parent | f220fed76f699f3a8f219ab85f82602d24387e80 (diff) |
allow both read and write callbacks for bufferevents to be NULL.
From Niels Provos via the libevent SVN
ok deraadt@
Diffstat (limited to 'lib/libevent')
-rw-r--r-- | lib/libevent/evbuffer.c | 11 | ||||
-rw-r--r-- | lib/libevent/event.3 | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/lib/libevent/evbuffer.c b/lib/libevent/evbuffer.c index 9a0a2a96381..ad3491f1960 100644 --- a/lib/libevent/evbuffer.c +++ b/lib/libevent/evbuffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: evbuffer.c,v 1.8 2006/03/18 20:23:42 brad Exp $ */ +/* $OpenBSD: evbuffer.c,v 1.9 2006/11/26 15:22:58 brad Exp $ */ /* * Copyright (c) 2002-2004 Niels Provos <provos@citi.umich.edu> @@ -138,7 +138,8 @@ bufferevent_readcb(int fd, short event, void *arg) } /* Invoke the user callback - must always be called last */ - (*bufev->readcb)(bufev, bufev->cbarg); + if (bufev->readcb != NULL) + (*bufev->readcb)(bufev, bufev->cbarg); return; reschedule: @@ -185,7 +186,8 @@ bufferevent_writecb(int fd, short event, void *arg) * Invoke the user callback if our buffer is drained or below the * low watermark. */ - if (EVBUFFER_LENGTH(bufev->output) <= bufev->wm_write.low) + if (bufev->writecb != NULL && + EVBUFFER_LENGTH(bufev->output) <= bufev->wm_write.low) (*bufev->writecb)(bufev, bufev->cbarg); return; @@ -205,6 +207,9 @@ bufferevent_writecb(int fd, short event, void *arg) * The read callback is invoked whenever we read new data. * The write callback is invoked whenever the output buffer is drained. * The error callback is invoked on a write/read error or on EOF. + * + * Both read and write callbacks maybe NULL. The error callback is not + * allowed to be NULL and have to be provided always. */ struct bufferevent * diff --git a/lib/libevent/event.3 b/lib/libevent/event.3 index 9bee9740f54..4bb7f80f4de 100644 --- a/lib/libevent/event.3 +++ b/lib/libevent/event.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: event.3,v 1.27 2006/10/21 12:04:18 deraadt Exp $ +.\" $OpenBSD: event.3,v 1.28 2006/11/26 15:22:58 brad Exp $ .\" .\" Copyright (c) 2000 Artur Grabowski <art@openbsd.org> .\" All rights reserved. @@ -484,6 +484,8 @@ The argument is specified by the fourth parameter A .Fa bufferevent struct pointer is returned on success, NULL on error. +Both the read and the write callback may be NULL. +The error callback has to be always provided. .Pp Once initialized, the bufferevent structure can be used repeatedly with bufferevent_enable() and bufferevent_disable(). |