On Mon, 2009-12-21 at 13:47 +0100, Julien Kerihuel wrote: > On Mon, 2009-12-21 at 16:21 +0530, Johnny Jacob wrote: > > Attached a updated patch. Also added a 'void *data' for the callback > to > > use. > > Hi Johnny, > > Patch applied in r1635. >
Found a bug in this patch. Select() modifies the timeval param. So it is not reliable to reuse timeval. We would have to refresh the value before every select() call. Attached patch explains it better. Apologies for overlooking this detail. Thanks. -- [johnnyjacob.org] "May you share freely, never taking more than you give "
commit e17347cb83d9ea4ebc7cdac2cf4fb22ff2395134 Author: Johnny Jacob <[email protected]> Date: Wed Jan 20 16:19:22 2010 +0530 MonitorNotification : Refresh tv values for select before calling it. Modified libmapi/IMAPISupport.c diff --git a/libmapi/IMAPISupport.c b/libmapi/IMAPISupport.c index f71b14e..1b54101 100644 --- a/libmapi/IMAPISupport.c +++ b/libmapi/IMAPISupport.c @@ -413,7 +413,7 @@ _PUBLIC_ enum MAPISTATUS MonitorNotification(struct mapi_session *session, void notify_ctx = session->notify_ctx; callback = cb_data ? cb_data->callback : NULL; data = cb_data ? cb_data->data : NULL; - tv = cb_data ? &cb_data->tv : NULL; + tv = cb_data ? malloc (sizeof (struct timeval)) : NULL; nread = 0; is_done = 0; @@ -421,6 +421,12 @@ _PUBLIC_ enum MAPISTATUS MonitorNotification(struct mapi_session *session, void FD_ZERO(&read_fds); FD_SET(notify_ctx->fd, &read_fds); + /* select() modifies tv to reflect the amount of time not slept.*/ + if (cb_data && tv) { + tv->tv_usec = cb_data->tv.tv_usec; + tv->tv_sec = cb_data->tv.tv_sec; + } + err = select(notify_ctx->fd + 1, &read_fds, NULL, NULL, tv); if (FD_ISSET(notify_ctx->fd, &read_fds)) { do { @@ -441,5 +447,7 @@ _PUBLIC_ enum MAPISTATUS MonitorNotification(struct mapi_session *session, void is_done = 1; } + free (tv); + return MAPI_E_SUCCESS; }
signature.asc
Description: This is a digitally signed message part
_______________________________________________ devel mailing list [email protected] http://mailman.openchange.org/listinfo/devel
