summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-05-20 20:28:45 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:22:16 -0500
commit772d8b0cd3e97d0314aab4195c8520711532d0f0 (patch)
treef1b01e50547c782e373c110b70c35731f0c314cf
parent9e5dbf3fd1c20b78e016080db90c87d97f441355 (diff)
downloadsamba-772d8b0cd3e97d0314aab4195c8520711532d0f0.tar.gz
samba-772d8b0cd3e97d0314aab4195c8520711532d0f0.tar.bz2
samba-772d8b0cd3e97d0314aab4195c8520711532d0f0.zip
r23025: Some logic simplifications
(This used to be commit d3f16722b2c3c68b03e55b5100d979921c3f284d)
-rw-r--r--source3/lib/messages.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 7ccc87a3cb..95f4aba4e7 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -208,32 +208,36 @@ static NTSTATUS message_notify(struct server_id procid)
errno = saved_errno;
}
- if (ret == -1) {
- if (errno == ESRCH) {
- DEBUG(2,("pid %d doesn't exist - deleting messages record\n",
- (int)pid));
- tdb_delete(tdb, message_key_pid(procid));
-
- /*
- * INVALID_HANDLE is the closest I can think of -- vl
- */
- return NT_STATUS_INVALID_HANDLE;
- }
+ if (ret == 0) {
+ return NT_STATUS_OK;
+ }
- DEBUG(2,("message to process %d failed - %s\n", (int)pid,
- strerror(errno)));
+ /*
+ * Something has gone wrong
+ */
+
+ if (errno == ESRCH) {
+ DEBUG(2,("pid %d doesn't exist - deleting messages record\n",
+ (int)pid));
+ tdb_delete(tdb, message_key_pid(procid));
/*
- * No call to map_nt_error_from_unix -- don't want to link in
- * errormap.o into lots of utils.
+ * INVALID_HANDLE is the closest I can think of -- vl
*/
-
- if (errno == EINVAL) return NT_STATUS_INVALID_PARAMETER;
- if (errno == EPERM) return NT_STATUS_ACCESS_DENIED;
- return NT_STATUS_UNSUCCESSFUL;
+ return NT_STATUS_INVALID_HANDLE;
}
- return NT_STATUS_OK;
+ DEBUG(2,("message to process %d failed - %s\n", (int)pid,
+ strerror(errno)));
+
+ /*
+ * No call to map_nt_error_from_unix -- don't want to link in
+ * errormap.o into lots of utils.
+ */
+
+ if (errno == EINVAL) return NT_STATUS_INVALID_PARAMETER;
+ if (errno == EPERM) return NT_STATUS_ACCESS_DENIED;
+ return NT_STATUS_UNSUCCESSFUL;
}
/****************************************************************************
@@ -243,7 +247,6 @@ static NTSTATUS message_notify(struct server_id procid)
static NTSTATUS message_send_pid(struct server_id pid, int msg_type,
const void *buf, size_t len)
{
- TDB_DATA kbuf;
TDB_DATA dbuf;
struct message_rec rec;
int ret;
@@ -266,8 +269,6 @@ static NTSTATUS message_send_pid(struct server_id pid, int msg_type,
rec.src = procid_self();
rec.len = buf ? len : 0;
- kbuf = message_key_pid(pid);
-
dbuf.dptr = (uint8 *)SMB_MALLOC(len + sizeof(rec));
if (!dbuf.dptr) {
return NT_STATUS_NO_MEMORY;
@@ -279,7 +280,7 @@ static NTSTATUS message_send_pid(struct server_id pid, int msg_type,
dbuf.dsize = len + sizeof(rec);
- ret = tdb_append(tdb, kbuf, dbuf);
+ ret = tdb_append(tdb, message_key_pid(pid), dbuf);
SAFE_FREE(dbuf.dptr);
@@ -297,14 +298,11 @@ static NTSTATUS message_send_pid(struct server_id pid, int msg_type,
unsigned int messages_pending_for_pid(struct server_id pid)
{
- TDB_DATA kbuf;
TDB_DATA dbuf;
uint8 *buf;
unsigned int message_count = 0;
- kbuf = message_key_pid(pid);
-
- dbuf = tdb_fetch(tdb, kbuf);
+ dbuf = tdb_fetch(tdb, message_key_pid(pid));
if (dbuf.dptr == NULL || dbuf.dsize == 0) {
SAFE_FREE(dbuf.dptr);
return 0;
@@ -337,7 +335,7 @@ static BOOL retrieve_all_messages(char **msgs_buf, size_t *total_len)
*msgs_buf = NULL;
*total_len = 0;
- kbuf = message_key_pid(pid_to_procid(sys_getpid()));
+ kbuf = message_key_pid(procid_self());
if (tdb_chainlock(tdb, kbuf) == -1)
return False;