diff options
-rw-r--r-- | source4/include/messages.h | 2 | ||||
-rw-r--r-- | source4/lib/messaging/messaging.c | 41 | ||||
-rw-r--r-- | source4/ntvfs/common/brlock.c | 4 | ||||
-rw-r--r-- | source4/ntvfs/common/opendb.c | 4 | ||||
-rw-r--r-- | source4/smbd/service.h | 2 | ||||
-rw-r--r-- | source4/torture/local/messaging.c | 12 |
6 files changed, 32 insertions, 33 deletions
diff --git a/source4/include/messages.h b/source4/include/messages.h index 3453a52bf1..96c1e81a31 100644 --- a/source4/include/messages.h +++ b/source4/include/messages.h @@ -22,6 +22,8 @@ #ifndef _MESSAGES_H_ #define _MESSAGES_H_ +struct messaging_context; + /* general messages */ #define MSG_DEBUG 1 #define MSG_PING 2 diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c index 13c1a049f8..afd18b4f2f 100644 --- a/source4/lib/messaging/messaging.c +++ b/source4/lib/messaging/messaging.c @@ -25,7 +25,7 @@ /* change the message version with any incompatible changes in the protocol */ #define MESSAGING_VERSION 1 -struct messaging_state { +struct messaging_context { servid_t server_id; struct socket_context *sock; char *path; @@ -43,13 +43,13 @@ struct dispatch_fn { struct dispatch_fn *next, *prev; uint32_t msg_type; void *private; - void (*fn)(void *msg_ctx, void *private, + void (*fn)(struct messaging_context *msg, void *private, uint32_t msg_type, servid_t server_id, DATA_BLOB *data); }; /* an individual message */ struct messaging_rec { - struct messaging_state *msg; + struct messaging_context *msg; struct socket_context *sock; struct fd_event *fde; const char *path; @@ -70,12 +70,12 @@ struct messaging_rec { /* A useful function for testing the message system. */ -static void ping_message(void *msg_ctx, void *private, +static void ping_message(struct messaging_context *msg, void *private, uint32_t msg_type, servid_t src, DATA_BLOB *data) { DEBUG(1,("INFO: Received PING message from server %u [%.*s]\n", (uint_t)src, data->length, data->data?(const char *)data->data:"")); - messaging_send(msg_ctx, src, MSG_PONG, data); + messaging_send(msg, src, MSG_PONG, data); } /* @@ -93,7 +93,7 @@ static char *messaging_path(TALLOC_CTX *mem_ctx, servid_t server_id) /* dispatch a fully received message */ -static void messaging_dispatch(struct messaging_state *msg, struct messaging_rec *rec) +static void messaging_dispatch(struct messaging_context *msg, struct messaging_rec *rec) { struct dispatch_fn *d, *next; for (d=msg->dispatch;d;d=next) { @@ -118,7 +118,7 @@ static void messaging_recv_handler(struct event_context *ev, struct fd_event *fd time_t t, uint16_t flags) { struct messaging_rec *rec = fde->private; - struct messaging_state *msg = rec->msg; + struct messaging_context *msg = rec->msg; NTSTATUS status; if (rec->ndone < sizeof(rec->header)) { @@ -189,7 +189,7 @@ static void messaging_recv_handler(struct event_context *ev, struct fd_event *fd static int rec_destructor(void *ptr) { struct messaging_rec *rec = ptr; - struct messaging_state *msg = rec->msg; + struct messaging_context *msg = rec->msg; event_remove_fd(msg->event.ev, rec->fde); return 0; } @@ -200,7 +200,7 @@ static int rec_destructor(void *ptr) static void messaging_listen_handler(struct event_context *ev, struct fd_event *fde, time_t t, uint16_t flags) { - struct messaging_state *msg = fde->private; + struct messaging_context *msg = fde->private; struct messaging_rec *rec; NTSTATUS status; struct fd_event fde2; @@ -234,11 +234,10 @@ static void messaging_listen_handler(struct event_context *ev, struct fd_event * /* Register a dispatch function for a particular message type. */ -void messaging_register(void *ctx, void *private, +void messaging_register(struct messaging_context *msg, void *private, uint32_t msg_type, - void (*fn)(void *, void *, uint32_t, servid_t, DATA_BLOB *)) + void (*fn)(struct messaging_context *, void *, uint32_t, servid_t, DATA_BLOB *)) { - struct messaging_state *msg = ctx; struct dispatch_fn *d; d = talloc_p(msg, struct dispatch_fn); @@ -251,9 +250,8 @@ void messaging_register(void *ctx, void *private, /* De-register the function for a particular message type. */ -void messaging_deregister(void *ctx, uint32_t msg_type, void *private) +void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private) { - struct messaging_state *msg = ctx; struct dispatch_fn *d, *next; for (d = msg->dispatch; d; d = next) { @@ -329,7 +327,7 @@ static void messaging_send_handler(struct event_context *ev, struct fd_event *fd static void messaging_backoff_handler(struct event_context *ev, struct timed_event *te, time_t t) { struct messaging_rec *rec = te->private; - struct messaging_state *msg = rec->msg; + struct messaging_context *msg = rec->msg; NTSTATUS status; struct fd_event fde; @@ -363,9 +361,8 @@ static void messaging_backoff_handler(struct event_context *ev, struct timed_eve /* Send a message to a particular server */ -NTSTATUS messaging_send(void *msg_ctx, servid_t server, uint32_t msg_type, DATA_BLOB *data) +NTSTATUS messaging_send(struct messaging_context *msg, servid_t server, uint32_t msg_type, DATA_BLOB *data) { - struct messaging_state *msg = msg_ctx; struct messaging_rec *rec; NTSTATUS status; struct fd_event fde; @@ -431,9 +428,9 @@ NTSTATUS messaging_send(void *msg_ctx, servid_t server, uint32_t msg_type, DATA_ /* destroy the messaging context */ -static int messaging_destructor(void *msg_ctx) +static int messaging_destructor(void *ptr) { - struct messaging_state *msg = msg_ctx; + struct messaging_context *msg = ptr; event_remove_fd(msg->event.ev, msg->event.fde); unlink(msg->path); return 0; @@ -442,13 +439,13 @@ static int messaging_destructor(void *msg_ctx) /* create the listening socket and setup the dispatcher */ -void *messaging_init(TALLOC_CTX *mem_ctx, servid_t server_id, struct event_context *ev) +struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, servid_t server_id, struct event_context *ev) { - struct messaging_state *msg; + struct messaging_context *msg; NTSTATUS status; struct fd_event fde; - msg = talloc_p(mem_ctx, struct messaging_state); + msg = talloc_p(mem_ctx, struct messaging_context); if (msg == NULL) { return NULL; } diff --git a/source4/ntvfs/common/brlock.c b/source4/ntvfs/common/brlock.c index 607947615e..d4b152cf42 100644 --- a/source4/ntvfs/common/brlock.c +++ b/source4/ntvfs/common/brlock.c @@ -61,7 +61,7 @@ struct brl_context { struct tdb_wrap *w; servid_t server; uint16_t tid; - void *messaging_ctx; + struct messaging_context *messaging_ctx; struct lock_struct last_lock_failure; }; @@ -72,7 +72,7 @@ struct brl_context { pending lock notifications. */ struct brl_context *brl_init(TALLOC_CTX *mem_ctx, servid_t server, uint16_t tid, - void *messaging_ctx) + struct messaging_context *messaging_ctx) { char *path; struct brl_context *brl; diff --git a/source4/ntvfs/common/opendb.c b/source4/ntvfs/common/opendb.c index a3924daf8e..d8ca4c999d 100644 --- a/source4/ntvfs/common/opendb.c +++ b/source4/ntvfs/common/opendb.c @@ -44,7 +44,7 @@ struct odb_context { struct tdb_wrap *w; servid_t server; uint16_t tid; - void *messaging_ctx; + struct messaging_context *messaging_ctx; }; /* @@ -76,7 +76,7 @@ struct odb_lock { notifications. */ struct odb_context *odb_init(TALLOC_CTX *mem_ctx, servid_t server, uint16_t tid, - void *messaging_ctx) + struct messaging_context *messaging_ctx) { char *path; struct odb_context *odb; diff --git a/source4/smbd/service.h b/source4/smbd/service.h index 93f24a34f9..2ac1988f3d 100644 --- a/source4/smbd/service.h +++ b/source4/smbd/service.h @@ -125,7 +125,7 @@ struct server_connection { struct server_service *service; - void *messaging_ctx; + struct messaging_context *messaging_ctx; }; #endif /* _SERVER_SERVICE_H */ diff --git a/source4/torture/local/messaging.c b/source4/torture/local/messaging.c index 38cebb4d39..18c4d9b03f 100644 --- a/source4/torture/local/messaging.c +++ b/source4/torture/local/messaging.c @@ -24,24 +24,24 @@ enum {MY_PING=1000, MY_PONG, MY_EXIT}; -static void ping_message(void *msg_ctx, void *private, +static void ping_message(struct messaging_context *msg, void *private, uint32_t msg_type, servid_t src, DATA_BLOB *data) { NTSTATUS status; - status = messaging_send(msg_ctx, src, MY_PONG, data); + status = messaging_send(msg, src, MY_PONG, data); if (!NT_STATUS_IS_OK(status)) { printf("pong failed - %s\n", nt_errstr(status)); } } -static void pong_message(void *msg_ctx, void *private, +static void pong_message(struct messaging_context *msg, void *private, uint32_t msg_type, servid_t src, DATA_BLOB *data) { int *count = private; (*count)++; } -static void exit_message(void *msg_ctx, void *private, +static void exit_message(struct messaging_context *msg, void *private, uint32_t msg_type, servid_t src, DATA_BLOB *data) { talloc_free(private); @@ -54,13 +54,13 @@ static void exit_message(void *msg_ctx, void *private, static BOOL test_ping_speed(TALLOC_CTX *mem_ctx) { struct event_context *ev = event_context_init(mem_ctx); - void *msg_ctx; + struct messaging_context *msg_ctx; int ping_count = 0; int pong_count = 0; BOOL ret = True; if (fork() == 0) { - void *msg_ctx2 = messaging_init(mem_ctx, 1, ev); + struct messaging_context *msg_ctx2 = messaging_init(mem_ctx, 1, ev); if (!msg_ctx2) { exit(1); |