summaryrefslogtreecommitdiffstats
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-09-14 17:52:07 +0200
committerStefan Metzmacher <metze@samba.org>2015-02-13 23:32:06 +0100
commit69f9ff7d82484803d589e6570e8989b49f3dde2c (patch)
tree92aa1a6f7cfd7842ffdc8495d850570eb52fb176 /source3/lib
parenta3efb70c87b489967fbf0a0b6873325a6a49bfea (diff)
downloadsamba-69f9ff7d82484803d589e6570e8989b49f3dde2c.tar.gz
samba-69f9ff7d82484803d589e6570e8989b49f3dde2c.tar.xz
samba-69f9ff7d82484803d589e6570e8989b49f3dde2c.zip
unix_msg: remove cookie from unix_msg_init
"pid" and "sock" are sufficient I guess as randomizers to distinguish messages. In theory, a pid could be recycled very quickly, which might mix up in-flight messages. But once a few messages have passed, "cookie" would be incremented as another indicator of a fresh message. Why? Remove messages_dgm dependency on samba-util Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/messages_dgm.c5
-rw-r--r--source3/lib/unix_msg/test_drain.c2
-rw-r--r--source3/lib/unix_msg/test_source.c2
-rw-r--r--source3/lib/unix_msg/tests.c9
-rw-r--r--source3/lib/unix_msg/unix_msg.c4
-rw-r--r--source3/lib/unix_msg/unix_msg.h3
6 files changed, 9 insertions, 16 deletions
diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index b64b2b0a75..1602caf9bd 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -144,7 +144,6 @@ int messaging_dgm_init(struct tevent_context *ev,
struct messaging_dgm_context *ctx;
int ret;
struct sockaddr_un socket_address;
- uint64_t cookie;
size_t len;
static bool have_dgm_context = false;
@@ -205,9 +204,7 @@ int messaging_dgm_init(struct tevent_context *ev,
unlink(socket_address.sun_path);
- generate_random_buffer((uint8_t *)&cookie, sizeof(cookie));
-
- ret = unix_msg_init(&socket_address, ctx->msg_callbacks, 1024, cookie,
+ ret = unix_msg_init(&socket_address, ctx->msg_callbacks, 1024,
messaging_dgm_recv, ctx, &ctx->dgm_ctx);
if (ret != 0) {
DEBUG(1, ("unix_msg_init failed: %s\n", strerror(ret)));
diff --git a/source3/lib/unix_msg/test_drain.c b/source3/lib/unix_msg/test_drain.c
index 9d740421f3..675ac6f94e 100644
--- a/source3/lib/unix_msg/test_drain.c
+++ b/source3/lib/unix_msg/test_drain.c
@@ -52,7 +52,7 @@ int main(int argc, const char *argv[])
exit(1);
}
- ret = unix_msg_init(&addr, funcs, 256, 1, recv_cb, &state, &ctx);
+ ret = unix_msg_init(&addr, funcs, 256, recv_cb, &state, &ctx);
if (ret != 0) {
fprintf(stderr, "unix_msg_init failed: %s\n",
strerror(ret));
diff --git a/source3/lib/unix_msg/test_source.c b/source3/lib/unix_msg/test_source.c
index 5224ebff6f..3b6526763a 100644
--- a/source3/lib/unix_msg/test_source.c
+++ b/source3/lib/unix_msg/test_source.c
@@ -46,7 +46,7 @@ int main(int argc, const char *argv[])
}
for (i=0; i<num_ctxs; i++) {
- ret = unix_msg_init(NULL, funcs, 256, 1, NULL, NULL,
+ ret = unix_msg_init(NULL, funcs, 256, NULL, NULL,
&ctxs[i]);
if (ret != 0) {
fprintf(stderr, "unix_msg_init failed: %s\n",
diff --git a/source3/lib/unix_msg/tests.c b/source3/lib/unix_msg/tests.c
index df094afb3d..9a15f9dff1 100644
--- a/source3/lib/unix_msg/tests.c
+++ b/source3/lib/unix_msg/tests.c
@@ -70,16 +70,14 @@ int main(void)
return 1;
}
- ret = unix_msg_init(&addr1, funcs, 256, 1,
- recv_cb, &state, &ctx1);
+ ret = unix_msg_init(&addr1, funcs, 256, recv_cb, &state, &ctx1);
if (ret != 0) {
fprintf(stderr, "unix_msg_init failed: %s\n",
strerror(ret));
return 1;
}
- ret = unix_msg_init(&addr1, funcs, 256, 1,
- recv_cb, &state, &ctx1);
+ ret = unix_msg_init(&addr1, funcs, 256, recv_cb, &state, &ctx1);
if (ret == 0) {
fprintf(stderr, "unix_msg_init succeeded unexpectedly\n");
return 1;
@@ -90,8 +88,7 @@ int main(void)
return 1;
}
- ret = unix_msg_init(&addr2, funcs, 256, 1,
- recv_cb, &state, &ctx2);
+ ret = unix_msg_init(&addr2, funcs, 256, recv_cb, &state, &ctx2);
if (ret != 0) {
fprintf(stderr, "unix_msg_init failed: %s\n",
strerror(ret));
diff --git a/source3/lib/unix_msg/unix_msg.c b/source3/lib/unix_msg/unix_msg.c
index e4eed1c2bc..6714f0d312 100644
--- a/source3/lib/unix_msg/unix_msg.c
+++ b/source3/lib/unix_msg/unix_msg.c
@@ -744,7 +744,7 @@ static void unix_msg_recv(struct unix_dgram_ctx *dgram_ctx,
int unix_msg_init(const struct sockaddr_un *addr,
const struct poll_funcs *ev_funcs,
- size_t fragment_len, uint64_t cookie,
+ size_t fragment_len,
void (*recv_callback)(struct unix_msg_ctx *ctx,
uint8_t *msg, size_t msg_len,
int *fds, size_t num_fds,
@@ -762,7 +762,7 @@ int unix_msg_init(const struct sockaddr_un *addr,
*ctx = (struct unix_msg_ctx) {
.fragment_len = fragment_len,
- .cookie = cookie,
+ .cookie = 1,
.recv_callback = recv_callback,
.private_data = private_data
};
diff --git a/source3/lib/unix_msg/unix_msg.h b/source3/lib/unix_msg/unix_msg.h
index 83d7067408..34c166bc66 100644
--- a/source3/lib/unix_msg/unix_msg.h
+++ b/source3/lib/unix_msg/unix_msg.h
@@ -75,7 +75,6 @@ struct unix_msg_ctx;
* @param[in] path The socket path
* @param[in] ev_funcs The event callback functions to use
* @param[in] fragment_size Maximum datagram size to send/receive
- * @param[in] cookie Random number to identify this context
* @param[in] recv_callback Function called when a message is received
* @param[in] private_data Private pointer for recv_callback
* @param[out] result The new struct unix_msg_ctx
@@ -85,7 +84,7 @@ struct unix_msg_ctx;
int unix_msg_init(const struct sockaddr_un *addr,
const struct poll_funcs *ev_funcs,
- size_t fragment_size, uint64_t cookie,
+ size_t fragment_size,
void (*recv_callback)(struct unix_msg_ctx *ctx,
uint8_t *msg, size_t msg_len,
int *fds, size_t num_fds,