svn commit: samba r23025 - in branches: SAMBA_3_0/source/lib
SAMBA_3_0_26/source/lib
vlendec at samba.org
vlendec at samba.org
Sun May 20 20:28:46 GMT 2007
Author: vlendec
Date: 2007-05-20 20:28:45 +0000 (Sun, 20 May 2007)
New Revision: 23025
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23025
Log:
Some logic simplifications
Modified:
branches/SAMBA_3_0/source/lib/messages.c
branches/SAMBA_3_0_26/source/lib/messages.c
Changeset:
Modified: branches/SAMBA_3_0/source/lib/messages.c
===================================================================
--- branches/SAMBA_3_0/source/lib/messages.c 2007-05-20 20:11:23 UTC (rev 23024)
+++ branches/SAMBA_3_0/source/lib/messages.c 2007-05-20 20:28:45 UTC (rev 23025)
@@ -208,32 +208,36 @@
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));
+ if (ret == 0) {
+ return NT_STATUS_OK;
+ }
- /*
- * INVALID_HANDLE is the closest I can think of -- vl
- */
- return NT_STATUS_INVALID_HANDLE;
- }
+ /*
+ * Something has gone wrong
+ */
- DEBUG(2,("message to process %d failed - %s\n", (int)pid,
- strerror(errno)));
+ 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_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 @@
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 @@
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 @@
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 @@
*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;
Modified: branches/SAMBA_3_0_26/source/lib/messages.c
===================================================================
--- branches/SAMBA_3_0_26/source/lib/messages.c 2007-05-20 20:11:23 UTC (rev 23024)
+++ branches/SAMBA_3_0_26/source/lib/messages.c 2007-05-20 20:28:45 UTC (rev 23025)
@@ -208,32 +208,36 @@
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));
+ if (ret == 0) {
+ return NT_STATUS_OK;
+ }
- /*
- * INVALID_HANDLE is the closest I can think of -- vl
- */
- return NT_STATUS_INVALID_HANDLE;
- }
+ /*
+ * Something has gone wrong
+ */
- DEBUG(2,("message to process %d failed - %s\n", (int)pid,
- strerror(errno)));
+ 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_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 @@
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 @@
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 @@
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 @@
*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;
More information about the samba-cvs
mailing list