From 66170ef8b36b499aa5b44ef10c1bd362a50f2636 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 3 Feb 2005 02:35:52 +0000 Subject: r5185: make all the events data structures private to events.c. This will make it possible to add optimisations to the events code such as keeping the next timed event in a sorted list, and using epoll for file descriptor events. I also removed the loop events code, as it wasn't being used anywhere, and changed timed events to always be one-shot (as adding a new timed event in the event handler is so easy to do if needed) (This used to be commit d7b4b6de51342a65bf46fce772d313f92f8d73d3) --- source4/ntvfs/cifs/vfs_cifs.c | 23 +++++++++++++++-------- source4/ntvfs/posix/pvfs_wait.c | 11 ++++------- 2 files changed, 19 insertions(+), 15 deletions(-) (limited to 'source4/ntvfs') diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c index c4ed9c172a..9d873722f9 100644 --- a/source4/ntvfs/cifs/vfs_cifs.c +++ b/source4/ntvfs/cifs/vfs_cifs.c @@ -65,14 +65,12 @@ static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin a handler for read events on a connection to a backend server */ static void cifs_socket_handler(struct event_context *ev, struct fd_event *fde, - struct timeval t, uint16_t flags) + struct timeval t, uint16_t flags, void *private) { - struct cvfs_private *private = fde->private; - struct smbsrv_tcon *tcon = private->tcon; + struct cvfs_private *cvfs = talloc_get_type(private, struct cvfs_private); + struct smbsrv_tcon *tcon = cvfs->tcon; - DEBUG(5,("cifs_socket_handler event on fd %d\n", fde->fd)); - - if (!smbcli_transport_process(private->transport)) { + if (!smbcli_transport_process(cvfs->transport)) { /* the connection to our server is dead */ talloc_free(tcon); } @@ -90,6 +88,7 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, const char *host, *user, *pass, *domain, *remote_share; struct smb_composite_connect io; struct composite_context *creq; + struct fd_event *fde; /* Here we need to determine which server to connect to. * For now we use parametric options, type cifs. @@ -144,8 +143,16 @@ static NTSTATUS cvfs_connect(struct ntvfs_module_context *ntvfs, /* we need to receive oplock break requests from the server */ smbcli_oplock_handler(private->transport, oplock_handler, private); - private->transport->socket->event.fde->handler = cifs_socket_handler; - private->transport->socket->event.fde->private = private; + /* take over event handling for this socket */ + talloc_free(private->transport->socket->event.fde); + fde = event_add_fd(private->transport->socket->event.ctx, + private, + socket_get_fd(private->transport->socket->sock), + EVENT_FD_READ | EVENT_FD_WRITE, + cifs_socket_handler, + private); + private->transport->socket->event.fde = fde; + private->map_generic = lp_parm_bool(req->tcon->service, "cifs", "mapgeneric", False); diff --git a/source4/ntvfs/posix/pvfs_wait.c b/source4/ntvfs/posix/pvfs_wait.c index 276b1d4e9a..7a8e6700c5 100644 --- a/source4/ntvfs/posix/pvfs_wait.c +++ b/source4/ntvfs/posix/pvfs_wait.c @@ -86,9 +86,9 @@ static void pvfs_wait_dispatch(struct messaging_context *msg, void *private, uin receive a timeout on a message wait */ static void pvfs_wait_timeout(struct event_context *ev, - struct timed_event *te, struct timeval t) + struct timed_event *te, struct timeval t, void *private) { - struct pvfs_wait *pwait = te->private; + struct pvfs_wait *pwait = talloc_get_type(private, struct pvfs_wait); struct smbsrv_request *req = pwait->req; pwait->reason = PVFS_WAIT_TIMEOUT; @@ -124,7 +124,6 @@ static int pvfs_wait_destructor(void *ptr) void (*fn)(void *, enum pvfs_wait_notice), void *private) { - struct timed_event te; struct pvfs_wait *pwait; pwait = talloc(pvfs, struct pvfs_wait); @@ -141,10 +140,8 @@ static int pvfs_wait_destructor(void *ptr) pwait->pvfs = pvfs; /* setup a timer */ - te.next_event = end_time; - te.handler = pvfs_wait_timeout; - te.private = pwait; - pwait->te = event_add_timed(pwait->ev, &te, pwait); + pwait->te = event_add_timed(pwait->ev, pwait, end_time, + pvfs_wait_timeout, pwait); /* register with the messaging subsystem for this message type */ -- cgit