summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@sernet.de>2007-11-25 09:33:29 +0100
committerVolker Lendecke <vl@sernet.de>2007-12-05 14:39:07 +0100
commit2b17840a0efdc7de3d9abfa262a64f73ada3f301 (patch)
tree0621e730e8f95a0f15863427e63604350d670543 /source3/lib
parent188daba1a7eaa7201bc29bfa1a958fe7a20fc790 (diff)
downloadsamba-2b17840a0efdc7de3d9abfa262a64f73ada3f301.tar.gz
samba-2b17840a0efdc7de3d9abfa262a64f73ada3f301.tar.bz2
samba-2b17840a0efdc7de3d9abfa262a64f73ada3f301.zip
Remove a static, and "signal_received" needs to be sig_atomic_t
(This used to be commit 8acd4a202f6b4518c2ce9cdd30f5dfb14b86c07c)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/messages_local.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/source3/lib/messages_local.c b/source3/lib/messages_local.c
index 5f7c46f61e..0cd482647a 100644
--- a/source3/lib/messages_local.c
+++ b/source3/lib/messages_local.c
@@ -46,7 +46,7 @@
#include "librpc/gen_ndr/messaging.h"
#include "librpc/gen_ndr/ndr_messaging.h"
-static int received_signal;
+static sig_atomic_t received_signal;
static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
struct server_id pid, int msg_type,
@@ -118,12 +118,14 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx,
Form a static tdb key from a pid.
******************************************************************/
-static TDB_DATA message_key_pid(struct server_id pid)
+static TDB_DATA message_key_pid(TALLOC_CTX *mem_ctx, struct server_id pid)
{
- static char key[20];
+ char *key;
TDB_DATA kbuf;
- slprintf(key, sizeof(key)-1, "PID/%s", procid_str_static(&pid));
+ key = talloc_asprintf(talloc_tos(), "PID/%s", procid_str_static(&pid));
+
+ SMB_ASSERT(key != NULL);
kbuf.dptr = (uint8 *)key;
kbuf.dsize = strlen(key)+1;
@@ -289,10 +291,10 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
{
struct messaging_array *msg_array;
struct messaging_rec *rec;
- TALLOC_CTX *mem_ctx;
NTSTATUS status;
- TDB_DATA key = message_key_pid(pid);
+ TDB_DATA key;
TDB_CONTEXT *tdb = (TDB_CONTEXT *)backend->private_data;
+ TALLOC_CTX *frame = talloc_stackframe();
/* NULL pointer means implicit length zero. */
if (!data->data) {
@@ -306,16 +308,14 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
SMB_ASSERT(procid_to_pid(&pid) > 0);
- if (!(mem_ctx = talloc_init("message_send_pid"))) {
- return NT_STATUS_NO_MEMORY;
- }
+ key = message_key_pid(frame, pid);
if (tdb_chainlock(tdb, key) == -1) {
- TALLOC_FREE(mem_ctx);
+ TALLOC_FREE(frame);
return NT_STATUS_LOCK_NOT_GRANTED;
}
- status = messaging_tdb_fetch(tdb, key, mem_ctx, &msg_array);
+ status = messaging_tdb_fetch(tdb, key, talloc_tos(), &msg_array);
if (!NT_STATUS_IS_OK(status)) {
goto done;
@@ -329,7 +329,7 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
goto done;
}
- if (!(rec = TALLOC_REALLOC_ARRAY(mem_ctx, msg_array->messages,
+ if (!(rec = TALLOC_REALLOC_ARRAY(talloc_tos(), msg_array->messages,
struct messaging_rec,
msg_array->num_messages+1))) {
status = NT_STATUS_NO_MEMORY;
@@ -356,12 +356,12 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx,
if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
DEBUG(2, ("pid %s doesn't exist - deleting messages record\n",
procid_str_static(&pid)));
- tdb_delete(tdb, message_key_pid(pid));
+ tdb_delete(tdb, message_key_pid(talloc_tos(), pid));
}
done:
tdb_chainunlock(tdb, key);
- TALLOC_FREE(mem_ctx);
+ TALLOC_FREE(frame);
return status;
}
@@ -374,10 +374,11 @@ static NTSTATUS retrieve_all_messages(TDB_CONTEXT *msg_tdb,
struct messaging_array **presult)
{
struct messaging_array *result;
- TDB_DATA key = message_key_pid(procid_self());
+ TDB_DATA key = message_key_pid(mem_ctx, procid_self());
NTSTATUS status;
if (tdb_chainlock(msg_tdb, key) == -1) {
+ TALLOC_FREE(key.dptr);
return NT_STATUS_LOCK_NOT_GRANTED;
}
@@ -393,6 +394,8 @@ static NTSTATUS retrieve_all_messages(TDB_CONTEXT *msg_tdb,
*presult = result;
}
+ TALLOC_FREE(key.dptr);
+
return status;
}