mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
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 236403cc4d
)
This commit is contained in:
parent
6e0a56f73b
commit
0798d54b4f
@ -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 *);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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]);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user