summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-02-03 11:25:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:30 -0500
commit0798d54b4fc28be881e2c4012663b1461bc85ba7 (patch)
tree532a93a578fd021c827bbb6bf5c65525b77671b7
parent6e0a56f73b7f75e45d97a574cf6fd1fc4f4bff9b (diff)
downloadsamba-0798d54b4fc28be881e2c4012663b1461bc85ba7.tar.gz
samba-0798d54b4fc28be881e2c4012663b1461bc85ba7.tar.bz2
samba-0798d54b4fc28be881e2c4012663b1461bc85ba7.zip
r5195: most events don't need the time of the event, so save a gettimeofday() call
and just use timeval_current() when its actually needed (This used to be commit 236403cc4dc2924ed6a898acae0bb44cc1688dcc)
-rw-r--r--source4/include/events.h2
-rw-r--r--source4/ldap_server/ldap_server.c6
-rw-r--r--source4/lib/events.c12
-rw-r--r--source4/lib/messaging/messaging.c6
-rw-r--r--source4/libcli/nbt/nbtsocket.c2
-rw-r--r--source4/libcli/raw/clisocket.c2
-rw-r--r--source4/libcli/raw/clitransport.c1
-rw-r--r--source4/libcli/resolve/host.c4
-rw-r--r--source4/librpc/rpc/dcerpc_sock.c2
-rw-r--r--source4/ntvfs/cifs/vfs_cifs.c2
-rw-r--r--source4/rpc_server/dcerpc_sock.c4
-rw-r--r--source4/smb_server/smb_server.c10
-rw-r--r--source4/smbd/service_stream.c8
-rw-r--r--source4/smbd/service_stream.h4
-rw-r--r--source4/torture/nbt/query.c2
-rw-r--r--source4/winbind/wb_server.c4
16 files changed, 32 insertions, 39 deletions
diff --git a/source4/include/events.h b/source4/include/events.h
index ec6493232e..e3973c3c48 100644
--- a/source4/include/events.h
+++ b/source4/include/events.h
@@ -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 *);
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index 87e46a3d51..70c9f62aec 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -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);
diff --git a/source4/lib/events.c b/source4/lib/events.c
index a478fc8a41..4907a60f01 100644
--- a/source4/lib/events.c
+++ b/source4/lib/events.c
@@ -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)
{
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 53b6f434f0..24205e5151 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -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;
diff --git a/source4/libcli/nbt/nbtsocket.c b/source4/libcli/nbt/nbtsocket.c
index 8e6fda1ece..be1b7547f1 100644
--- a/source4/libcli/nbt/nbtsocket.c
+++ b/source4/libcli/nbt/nbtsocket.c
@@ -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);
diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c
index f9e662714b..69de86088a 100644
--- a/source4/libcli/raw/clisocket.c
+++ b/source4/libcli/raw/clisocket.c
@@ -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);
diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c
index 21303a34aa..d614d80d99 100644
--- a/source4/libcli/raw/clitransport.c
+++ b/source4/libcli/raw/clitransport.c
@@ -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,
diff --git a/source4/libcli/resolve/host.c b/source4/libcli/resolve/host.c
index 977c804a4a..4df8f27534 100644
--- a/source4/libcli/resolve/host.c
+++ b/source4/libcli/resolve/host.c
@@ -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]);
diff --git a/source4/librpc/rpc/dcerpc_sock.c b/source4/librpc/rpc/dcerpc_sock.c
index df4591d20e..63371eefd2 100644
--- a/source4/librpc/rpc/dcerpc_sock.c
+++ b/source4/librpc/rpc/dcerpc_sock.c
@@ -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;
diff --git a/source4/ntvfs/cifs/vfs_cifs.c b/source4/ntvfs/cifs/vfs_cifs.c
index 9d873722f9..c64e4d3c84 100644
--- a/source4/ntvfs/cifs/vfs_cifs.c
+++ b/source4/ntvfs/cifs/vfs_cifs.c
@@ -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;
diff --git a/source4/rpc_server/dcerpc_sock.c b/source4/rpc_server/dcerpc_sock.c
index 67b9065507..618f5af20f 100644
--- a/source4/rpc_server/dcerpc_sock.c
+++ b/source4/rpc_server/dcerpc_sock.c
@@ -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;
diff --git a/source4/smb_server/smb_server.c b/source4/smb_server/smb_server.c
index f1f73014f1..3946e9ab13 100644
--- a/source4/smb_server/smb_server.c
+++ b/source4/smb_server/smb_server.c
@@ -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);
diff --git a/source4/smbd/service_stream.c b/source4/smbd/service_stream.c
index 00fd9c470a..767f2052c3 100644
--- a/source4/smbd/service_stream.c
+++ b/source4/smbd/service_stream.c
@@ -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);
diff --git a/source4/smbd/service_stream.h b/source4/smbd/service_stream.h
index b9d4d4cc77..3ae7107419 100644
--- a/source4/smbd/service_stream.h
+++ b/source4/smbd/service_stream.h
@@ -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);
};
diff --git a/source4/torture/nbt/query.c b/source4/torture/nbt/query.c
index b89a774e06..942c7fbef4 100644
--- a/source4/torture/nbt/query.c
+++ b/source4/torture/nbt/query.c
@@ -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);
diff --git a/source4/winbind/wb_server.c b/source4/winbind/wb_server.c
index 8e5f8abd3e..54d01eda69 100644
--- a/source4/winbind/wb_server.c
+++ b/source4/winbind/wb_server.c
@@ -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);