r5195: most events don't need the time of the event, so save a gettimeofday() call
authorAndrew Tridgell <tridge@samba.org>
Thu, 3 Feb 2005 11:25:52 +0000 (11:25 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:09:30 +0000 (13:09 -0500)
and just use timeval_current() when its actually needed
(This used to be commit 236403cc4dc2924ed6a898acae0bb44cc1688dcc)

16 files changed:
source4/include/events.h
source4/ldap_server/ldap_server.c
source4/lib/events.c
source4/lib/messaging/messaging.c
source4/libcli/nbt/nbtsocket.c
source4/libcli/raw/clisocket.c
source4/libcli/raw/clitransport.c
source4/libcli/resolve/host.c
source4/librpc/rpc/dcerpc_sock.c
source4/ntvfs/cifs/vfs_cifs.c
source4/rpc_server/dcerpc_sock.c
source4/smb_server/smb_server.c
source4/smbd/service_stream.c
source4/smbd/service_stream.h
source4/torture/nbt/query.c
source4/winbind/wb_server.c

index ec6493232eb4a8c09158e3e321c9640b310410cf..e3973c3c48578c4c02ee92018b435fb00796a213 100644 (file)
@@ -26,7 +26,7 @@ struct timed_event;
 
 /* event handler types */
 typedef void (*event_fd_handler_t)(struct event_context *, struct fd_event *, 
-                                  struct timeval , uint16_t , void *);
+                                  uint16_t , void *);
 typedef void (*event_timed_handler_t)(struct event_context *, struct timed_event *, 
                                      struct timeval , void *);
 
index 87e46a3d51b04e0a12b9bb28375946f4d233e725..70c9f62aec21cbade58a6404e298a91b1c786018 100644 (file)
@@ -328,8 +328,7 @@ NTSTATUS ldapsrv_flush_responses(struct ldapsrv_connection *conn)
 /*
   called when a LDAP socket becomes readable
 */
-static void ldapsrv_recv(struct stream_connection *conn, struct timeval t,
-                        uint16_t flags)
+static void ldapsrv_recv(struct stream_connection *conn, uint16_t flags)
 {
        struct ldapsrv_connection *ldap_conn = talloc_get_type(conn->private, struct ldapsrv_connection);
        uint8_t *buf;
@@ -424,8 +423,7 @@ static void ldapsrv_recv(struct stream_connection *conn, struct timeval t,
 /*
   called when a LDAP socket becomes writable
 */
-static void ldapsrv_send(struct stream_connection *conn, struct timeval t,
-                        uint16_t flags)
+static void ldapsrv_send(struct stream_connection *conn, uint16_t flags)
 {
        struct ldapsrv_connection *ldap_conn = talloc_get_type(conn->private, struct ldapsrv_connection);
 
index a478fc8a411187c6d18715b2ad4f83929507ab3d..4907a60f01e0c6171647d7d9759d6f570099b2dc 100644 (file)
@@ -359,7 +359,6 @@ static int event_loop_epoll(struct event_context *ev, struct timeval *tvalp)
        struct epoll_event events[maxevents];
        uint32_t destruction_count = ev->destruction_count;
        int timeout = -1;
-       struct timeval t;
 
        if (tvalp) {
                timeout = (tvalp->tv_usec / 1000) + (tvalp->tv_sec*1000);
@@ -367,7 +366,7 @@ static int event_loop_epoll(struct event_context *ev, struct timeval *tvalp)
 
        ret = epoll_wait(ev->epoll_fd, events, maxevents, timeout);
 
-       if (ret == -1) {
+       if (ret == -1 && errno != EINTR) {
                epoll_fallback_to_select(ev, "epoll_wait() failed");
                return -1;
        }
@@ -377,8 +376,6 @@ static int event_loop_epoll(struct event_context *ev, struct timeval *tvalp)
                return 0;
        }
 
-       t = timeval_current();
-
        for (i=0;i<ret;i++) {
                struct fd_event *fde = talloc_get_type(events[i].data.ptr, 
                                                       struct fd_event);
@@ -391,7 +388,7 @@ static int event_loop_epoll(struct event_context *ev, struct timeval *tvalp)
                if (events[i].events & EPOLLIN) flags |= EVENT_FD_READ;
                if (events[i].events & EPOLLOUT) flags |= EVENT_FD_WRITE;
                if (flags) {
-                       fde->handler(ev, fde, t, flags, fde->private);
+                       fde->handler(ev, fde, flags, fde->private);
                        if (destruction_count != ev->destruction_count) {
                                break;
                        }
@@ -451,7 +448,6 @@ static int event_loop_select(struct event_context *ev, struct timeval *tvalp)
        }
 
        if (selrtn > 0) {
-               struct timeval t = timeval_current();
                /* at least one file descriptor is ready - check
                   which ones and call the handler, being careful to allow
                   the handler to remove itself when called */
@@ -460,7 +456,7 @@ static int event_loop_select(struct event_context *ev, struct timeval *tvalp)
                        if (FD_ISSET(fe->fd, &r_fds)) flags |= EVENT_FD_READ;
                        if (FD_ISSET(fe->fd, &w_fds)) flags |= EVENT_FD_WRITE;
                        if (flags) {
-                               fe->handler(ev, fe, t, flags, fe->private);
+                               fe->handler(ev, fe, flags, fe->private);
                                if (destruction_count != ev->destruction_count) {
                                        break;
                                }
@@ -472,7 +468,7 @@ static int event_loop_select(struct event_context *ev, struct timeval *tvalp)
 }              
 
 /*
-  do a single event loop using the events defined in ev this function
+  do a single event loop using the events defined in ev 
 */
 int event_loop_once(struct event_context *ev)
 {
index 53b6f434f067e392dac81bc8c53f2c3428b60143..24205e5151035535c93fa9cb9086d8a13fce72ea 100644 (file)
@@ -122,7 +122,7 @@ static void messaging_dispatch(struct messaging_context *msg, struct messaging_r
   handle IO for a single message
 */
 static void messaging_recv_handler(struct event_context *ev, struct fd_event *fde, 
-                                  struct timeval t, uint16_t flags, void *private)
+                                  uint16_t flags, void *private)
 {
        struct messaging_rec *rec = talloc_get_type(private, struct messaging_rec);
        struct messaging_context *msg = rec->msg;
@@ -192,7 +192,7 @@ static void messaging_recv_handler(struct event_context *ev, struct fd_event *fd
   handle a new incoming connection
 */
 static void messaging_listen_handler(struct event_context *ev, struct fd_event *fde, 
-                                    struct timeval t, uint16_t flags, void *private)
+                                    uint16_t flags, void *private)
 {
        struct messaging_context *msg = talloc_get_type(private, 
                                                        struct messaging_context);
@@ -257,7 +257,7 @@ void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void
   handle IO for sending a message
 */
 static void messaging_send_handler(struct event_context *ev, struct fd_event *fde, 
-                                  struct timeval t, uint16_t flags, void *private)
+                                  uint16_t flags, void *private)
 {
        struct messaging_rec *rec = talloc_get_type(private, struct messaging_rec);
        NTSTATUS status;
index 8e6fda1ece0ac0651f78b2d67c3af0a4ee00ac01..be1b7547f1179f841b0663e751ebe7e9ad3312d9 100644 (file)
@@ -210,7 +210,7 @@ static void nbt_name_socket_recv(struct nbt_name_socket *nbtsock)
   handle fd events on a nbt_name_socket
 */
 static void nbt_name_socket_handler(struct event_context *ev, struct fd_event *fde,
-                                   struct timeval t, uint16_t flags, void *private)
+                                   uint16_t flags, void *private)
 {
        struct nbt_name_socket *nbtsock = talloc_get_type(private, 
                                                          struct nbt_name_socket);
index f9e662714b45ede8da05f8322f9ecbe21df44357..69de86088ac10011c43a1654928b6f471823973f 100644 (file)
@@ -73,7 +73,7 @@ static NTSTATUS smbcli_sock_connect_one(struct smbcli_socket *sock,
   has either completed the connect() or has returned an error
 */
 static void smbcli_sock_connect_handler(struct event_context *ev, struct fd_event *fde, 
-                                       struct timeval t, uint16_t flags, void *private)
+                                       uint16_t flags, void *private)
 {
        struct composite_context *c = talloc_get_type(private, struct composite_context);
        struct clisocket_connect *conn = talloc_get_type(c->private, struct clisocket_connect);
index 21303a34aa826af894defeeea4fd435cd3844a68..d614d80d9924b9f6ee452cfcf2a5183fd04e935a 100644 (file)
@@ -35,7 +35,6 @@ static void smbcli_transport_process_send(struct smbcli_transport *transport);
 */
 static void smbcli_transport_event_handler(struct event_context *ev, 
                                           struct fd_event *fde, 
-                                          struct timeval t, 
                                           uint16_t flags, void *private)
 {
        struct smbcli_transport *transport = talloc_get_type(private,
index 977c804a4accdfefbd77f5c422cbce1d863529b9..4df8f27534ae32fdf2624d5f0541d31066162946 100644 (file)
@@ -83,7 +83,7 @@ static void run_child(struct composite_context *c, int fd)
   handle a read event on the pipe
 */
 static void pipe_handler(struct event_context *ev, struct fd_event *fde, 
-                        struct timeval t, uint16_t flags, void *private)
+                        uint16_t flags, void *private)
 {
        struct composite_context *c = talloc_get_type(private, struct composite_context);
        struct host_state *state = talloc_get_type(c->private, struct host_state);
@@ -160,7 +160,7 @@ struct composite_context *resolve_name_host_send(struct nbt_name *name,
 
        /* we need to put the child in our event context so
           we know when the gethostbyname() has finished */
-       state->fde = event_add_fd(c->event_ctx, state, state->child_fd, EVENT_FD_READ, 
+       state->fde = event_add_fd(c->event_ctx, c, state->child_fd, EVENT_FD_READ, 
                                  pipe_handler, c);
        if (state->fde == NULL) {
                close(fd[0]);
index df4591d20e2c5b586dc2828aa639fc27b117f4a5..63371eefd2af60e6586e1f1171749a1f60cdfe7c 100644 (file)
@@ -192,7 +192,7 @@ static void sock_process_recv(struct dcerpc_connection *p)
   called when a IO is triggered by the events system
 */
 static void sock_io_handler(struct event_context *ev, struct fd_event *fde, 
-                           struct timeval t, uint16_t flags, void *private)
+                           uint16_t flags, void *private)
 {
        struct dcerpc_connection *p = talloc_get_type(private, struct dcerpc_connection);
        struct sock_private *sock = p->transport.private;
index 9d873722f9f2c8f8f57d3a704845d51a7ca6d696..c64e4d3c84a2141d3cf158ba25209396980975c9 100644 (file)
@@ -65,7 +65,7 @@ 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, void *private)
+                               uint16_t flags, void *private)
 {
        struct cvfs_private *cvfs = talloc_get_type(private, struct cvfs_private);
        struct smbsrv_tcon *tcon = cvfs->tcon;
index 67b9065507392b7a48efc706ed5e70fc523030e7..618f5af20f178fa009a3939eb3c654d6e82c792e 100644 (file)
@@ -78,7 +78,7 @@ void dcesrv_sock_accept(struct stream_connection *srv_conn)
        return; 
 }
 
-void dcesrv_sock_recv(struct stream_connection *conn, struct timeval t, uint16_t flags)
+void dcesrv_sock_recv(struct stream_connection *conn, uint16_t flags)
 {
        NTSTATUS status;
        struct dcesrv_connection *dce_conn = talloc_get_type(conn->private, struct dcesrv_connection);
@@ -116,7 +116,7 @@ void dcesrv_sock_recv(struct stream_connection *conn, struct timeval t, uint16_t
        }
 }
 
-void dcesrv_sock_send(struct stream_connection *conn, struct timeval t, uint16_t flags)
+void dcesrv_sock_send(struct stream_connection *conn, uint16_t flags)
 {
        struct dcesrv_connection *dce_conn = talloc_get_type(conn->private, struct dcesrv_connection);
        NTSTATUS status;
index f1f73014f17eb8bcf740dc494b798dec5bb28a3c..3946e9ab137c2c22af85bcdd45833adbe00d2af3 100644 (file)
@@ -67,7 +67,7 @@ static void construct_reply(struct smbsrv_request *req);
 receive a SMB request header from the wire, forming a request_context
 from the result
 ****************************************************************************/
-static NTSTATUS receive_smb_request(struct smbsrv_connection *smb_conn, struct timeval t)
+static NTSTATUS receive_smb_request(struct smbsrv_connection *smb_conn)
 {
        NTSTATUS status;
        ssize_t len;
@@ -140,7 +140,7 @@ static NTSTATUS receive_smb_request(struct smbsrv_connection *smb_conn, struct t
        }
 
        /* we have a full packet */
-       req->request_time = t;
+       req->request_time = timeval_current();
        req->chained_fnum = -1;
        req->in.allocated = req->in.size;
        req->in.hdr = req->in.buffer + NBT_HDR_SIZE;
@@ -653,14 +653,14 @@ void smbsrv_terminate_connection(struct smbsrv_connection *smb_conn, const char
 /*
   called when a SMB socket becomes readable
 */
-static void smbsrv_recv(struct stream_connection *conn, struct timeval t, uint16_t flags)
+static void smbsrv_recv(struct stream_connection *conn, uint16_t flags)
 {
        struct smbsrv_connection *smb_conn = talloc_get_type(conn->private, struct smbsrv_connection);
        NTSTATUS status;
 
        DEBUG(10,("smbsrv_recv\n"));
 
-       status = receive_smb_request(smb_conn, t);
+       status = receive_smb_request(smb_conn);
        if (NT_STATUS_IS_ERR(status)) {
                talloc_free(conn->event.fde);
                conn->event.fde = NULL;
@@ -675,7 +675,7 @@ static void smbsrv_recv(struct stream_connection *conn, struct timeval t, uint16
 /*
   called when a SMB socket becomes writable
 */
-static void smbsrv_send(struct stream_connection *conn, struct timeval t, uint16_t flags)
+static void smbsrv_send(struct stream_connection *conn, uint16_t flags)
 {
        struct smbsrv_connection *smb_conn = talloc_get_type(conn->private, struct smbsrv_connection);
 
index 00fd9c470a680d62f27863fdd91b51cf9fec8d6a..767f2052c3f1295ab65805cfa1408ad90f652a5c 100644 (file)
@@ -61,17 +61,17 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char
   the select loop has indicated that a stream is ready for IO
 */
 static void stream_io_handler(struct event_context *ev, struct fd_event *fde, 
-                             struct timeval t, uint16_t flags, void *private)
+                             uint16_t flags, void *private)
 {
        struct stream_connection *conn = talloc_get_type(private, 
                                                         struct stream_connection);
        if (flags & EVENT_FD_WRITE) {
-               conn->ops->send_handler(conn, t, flags);
+               conn->ops->send_handler(conn, flags);
                return;
        }
 
        if (flags & EVENT_FD_READ) {
-               conn->ops->recv_handler(conn, t, flags);
+               conn->ops->recv_handler(conn, flags);
        }
 }
 
@@ -126,7 +126,7 @@ static void stream_new_connection(struct event_context *ev,
   called when someone opens a connection to one of our listening ports
 */
 static void stream_accept_handler(struct event_context *ev, struct fd_event *fde, 
-                                 struct timeval t, uint16_t flags, void *private)
+                                 uint16_t flags, void *private)
 {
        struct stream_socket *stream_socket = talloc_get_type(private, struct stream_socket);
 
index b9d4d4cc7717eef37eee5e5e3a3293ae1f6162c5..3ae710741959e97ec3e8518758caef6408e34484 100644 (file)
@@ -52,6 +52,6 @@ struct stream_server_ops {
        /* the name of the server_service */
        const char *name;
        void (*accept_connection)(struct stream_connection *);
-       void (*recv_handler)(struct stream_connection *, struct timeval, uint16_t);
-       void (*send_handler)(struct stream_connection *, struct timeval, uint16_t);
+       void (*recv_handler)(struct stream_connection *, uint16_t);
+       void (*send_handler)(struct stream_connection *, uint16_t);
 };
index b89a774e06e8689c2313fc1e3efcfff2053bd272..942c7fbef4d4730a7e09c78570c371c29f3ef065 100644 (file)
@@ -75,7 +75,7 @@ static BOOL bench_namequery(TALLOC_CTX *mem_ctx, struct nbt_name *name, const ch
                        req->async.fn = increment_handler;
                        req->async.private = result;
                        num_sent++;
-                       if (num_sent % 100 == 0) {
+                       if (num_sent % 1000 == 0) {
                                printf("%.1f queries per second (%d failures)  \r", 
                                       result->num_pass / timeval_elapsed(&tv),
                                       result->num_fail);
index 8e5f8abd3e84ee96c44bcbfee4ba5c9c4432d258..54d01eda69481f2ed450f6bfa7939334539a9634 100644 (file)
@@ -60,7 +60,7 @@ static void winbind_accept(struct stream_connection *conn)
 /*
   receive some data on a winbind connection
 */
-static void winbind_recv(struct stream_connection *conn, struct timeval t, uint16_t flags)
+static void winbind_recv(struct stream_connection *conn, uint16_t flags)
 {
        struct wbserver_connection *wbconn = talloc_get_type(conn->private, struct wbserver_connection);
        NTSTATUS status;
@@ -95,7 +95,7 @@ static void winbind_recv(struct stream_connection *conn, struct timeval t, uint1
 /*
   called when we can write to a connection
 */
-static void winbind_send(struct stream_connection *conn, struct timeval t, uint16_t flags)
+static void winbind_send(struct stream_connection *conn, uint16_t flags)
 {
        struct wbserver_connection *wbconn = talloc_get_type(conn->private, struct wbserver_connection);