svn commit: samba r21115 - in branches/SAMBA_3_0/source: lib libsmb
rpc_server smbd utils
vlendec at samba.org
vlendec at samba.org
Thu Feb 1 19:29:08 GMT 2007
Author: vlendec
Date: 2007-02-01 19:29:07 +0000 (Thu, 01 Feb 2007)
New Revision: 21115
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21115
Log:
notify_internal.c needs to remove the table entry if a process has crashed. So
it needs the specific error message.
Make messages.c return NTSTATUS and specificially NT_STATUS_INVALID_HANDLE if
sending to a non-existent process.
Volker
Modified:
branches/SAMBA_3_0/source/lib/messages.c
branches/SAMBA_3_0/source/libsmb/clidgram.c
branches/SAMBA_3_0/source/rpc_server/srv_srvsvc_nt.c
branches/SAMBA_3_0/source/smbd/open.c
branches/SAMBA_3_0/source/utils/smbcontrol.c
Changeset:
Modified: branches/SAMBA_3_0/source/lib/messages.c
===================================================================
--- branches/SAMBA_3_0/source/lib/messages.c 2007-02-01 16:22:07 UTC (rev 21114)
+++ branches/SAMBA_3_0/source/lib/messages.c 2007-02-01 19:29:07 UTC (rev 21115)
@@ -166,7 +166,7 @@
then delete its record in the database.
****************************************************************************/
-static BOOL message_notify(struct process_id procid)
+static NTSTATUS message_notify(struct process_id procid)
{
pid_t pid = procid.pid;
int ret;
@@ -191,25 +191,40 @@
if (ret == -1) {
if (errno == ESRCH) {
- DEBUG(2,("pid %d doesn't exist - deleting messages record\n", (int)pid));
+ DEBUG(2,("pid %d doesn't exist - deleting messages record\n",
+ (int)pid));
tdb_delete(tdb, message_key_pid(procid));
- } else {
- DEBUG(2,("message to process %d failed - %s\n", (int)pid, strerror(errno)));
+
+ /*
+ * INVALID_HANDLE is the closest I can think of -- vl
+ */
+ return NT_STATUS_INVALID_HANDLE;
}
- return False;
+
+ 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;
}
- return True;
+ return NT_STATUS_OK;
}
/****************************************************************************
Send a message to a particular pid.
****************************************************************************/
-static BOOL message_send_pid_internal(struct process_id pid, int msg_type,
- const void *buf, size_t len,
- BOOL duplicates_allowed,
- unsigned int timeout)
+static NTSTATUS message_send_pid_internal(struct process_id pid, int msg_type,
+ const void *buf, size_t len,
+ BOOL duplicates_allowed,
+ unsigned int timeout)
{
TDB_DATA kbuf;
TDB_DATA dbuf;
@@ -239,8 +254,9 @@
kbuf = message_key_pid(pid);
dbuf.dptr = (char *)SMB_MALLOC(len + sizeof(rec));
- if (!dbuf.dptr)
- return False;
+ if (!dbuf.dptr) {
+ return NT_STATUS_NO_MEMORY;
+ }
memcpy(dbuf.dptr, &rec, sizeof(rec));
if (len > 0 && buf)
@@ -255,13 +271,15 @@
/* lock the record for the destination */
if (timeout) {
if (tdb_chainlock_with_timeout(tdb, kbuf, timeout) == -1) {
- DEBUG(0,("message_send_pid_internal: failed to get chainlock with timeout %ul.\n", timeout));
- return False;
+ DEBUG(0,("message_send_pid_internal: failed to get "
+ "chainlock with timeout %ul.\n", timeout));
+ return NT_STATUS_IO_TIMEOUT;
}
} else {
if (tdb_chainlock(tdb, kbuf) == -1) {
- DEBUG(0,("message_send_pid_internal: failed to get chainlock.\n"));
- return False;
+ DEBUG(0,("message_send_pid_internal: failed to get "
+ "chainlock.\n"));
+ return NT_STATUS_LOCK_NOT_GRANTED;
}
}
tdb_append(tdb, kbuf, dbuf);
@@ -275,13 +293,15 @@
/* lock the record for the destination */
if (timeout) {
if (tdb_chainlock_with_timeout(tdb, kbuf, timeout) == -1) {
- DEBUG(0,("message_send_pid_internal: failed to get chainlock with timeout %ul.\n", timeout));
- return False;
+ DEBUG(0,("message_send_pid_internal: failed to get chainlock "
+ "with timeout %ul.\n", timeout));
+ return NT_STATUS_IO_TIMEOUT;
}
} else {
if (tdb_chainlock(tdb, kbuf) == -1) {
- DEBUG(0,("message_send_pid_internal: failed to get chainlock.\n"));
- return False;
+ DEBUG(0,("message_send_pid_internal: failed to get "
+ "chainlock.\n"));
+ return NT_STATUS_LOCK_NOT_GRANTED;
}
}
@@ -310,10 +330,11 @@
if (!memcmp(ptr, &rec, sizeof(rec))) {
if (!len || (len && !memcmp( ptr + sizeof(rec), buf, len))) {
tdb_chainunlock(tdb, kbuf);
- DEBUG(10,("message_send_pid_internal: discarding duplicate message.\n"));
+ DEBUG(10,("message_send_pid_internal: discarding "
+ "duplicate message.\n"));
SAFE_FREE(dbuf.dptr);
SAFE_FREE(old_dbuf.dptr);
- return True;
+ return NT_STATUS_OK;
}
}
memcpy(&prec, ptr, sizeof(prec));
@@ -336,19 +357,23 @@
Send a message to a particular pid - no timeout.
****************************************************************************/
-BOOL message_send_pid(struct process_id pid, int msg_type, const void *buf, size_t len, BOOL duplicates_allowed)
+NTSTATUS message_send_pid(struct process_id pid, int msg_type, const void *buf,
+ size_t len, BOOL duplicates_allowed)
{
- return message_send_pid_internal(pid, msg_type, buf, len, duplicates_allowed, 0);
+ return message_send_pid_internal(pid, msg_type, buf, len,
+ duplicates_allowed, 0);
}
/****************************************************************************
Send a message to a particular pid, with timeout in seconds.
****************************************************************************/
-BOOL message_send_pid_with_timeout(struct process_id pid, int msg_type, const void *buf, size_t len,
- BOOL duplicates_allowed, unsigned int timeout)
+NTSTATUS message_send_pid_with_timeout(struct process_id pid, int msg_type,
+ const void *buf, size_t len,
+ BOOL duplicates_allowed, unsigned int timeout)
{
- return message_send_pid_internal(pid, msg_type, buf, len, duplicates_allowed, timeout);
+ return message_send_pid_internal(pid, msg_type, buf, len, duplicates_allowed,
+ timeout);
}
/****************************************************************************
@@ -586,6 +611,7 @@
{
struct connections_data crec;
struct msg_all *msg_all = (struct msg_all *)state;
+ NTSTATUS status;
if (dbuf.dsize != sizeof(crec))
return 0;
@@ -603,18 +629,17 @@
/* If the msg send fails because the pid was not found (i.e. smbd died),
* the msg has already been deleted from the messages.tdb.*/
- if (!message_send_pid(crec.pid, msg_all->msg_type,
- msg_all->buf, msg_all->len,
- msg_all->duplicates)) {
+ status = message_send_pid(crec.pid, msg_all->msg_type,
+ msg_all->buf, msg_all->len,
+ msg_all->duplicates);
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
/* If the pid was not found delete the entry from connections.tdb */
- if (errno == ESRCH) {
- DEBUG(2,("pid %s doesn't exist - deleting connections %d [%s]\n",
- procid_str_static(&crec.pid),
- crec.cnum, crec.name));
- tdb_delete(the_tdb, kbuf);
- }
+ DEBUG(2,("pid %s doesn't exist - deleting connections %d [%s]\n",
+ procid_str_static(&crec.pid), crec.cnum, crec.name));
+ tdb_delete(the_tdb, kbuf);
}
msg_all->n_sent++;
return 0;
@@ -806,8 +831,7 @@
uint32_t msg_type, DATA_BLOB *data)
{
return message_send_pid_internal(server.id, msg_type, data->data,
- data->length, True, 0)
- ? NT_STATUS_OK : NT_STATUS_ACCESS_DENIED;
+ data->length, True, 0);
}
/** @} **/
Modified: branches/SAMBA_3_0/source/libsmb/clidgram.c
===================================================================
--- branches/SAMBA_3_0/source/libsmb/clidgram.c 2007-02-01 16:22:07 UTC (rev 21114)
+++ branches/SAMBA_3_0/source/libsmb/clidgram.c 2007-02-01 19:29:07 UTC (rev 21115)
@@ -101,8 +101,9 @@
DEBUGADD(4,("to %s IP %s\n", nmb_namestr(&dgram->dest_name),
inet_ntoa(dest_ip)));
- return message_send_pid(pid_to_procid(nmbd_pid), MSG_SEND_PACKET, &p, sizeof(p),
- False);
+ return NT_STATUS_IS_OK(message_send_pid(pid_to_procid(nmbd_pid),
+ MSG_SEND_PACKET, &p, sizeof(p),
+ False));
}
/*
Modified: branches/SAMBA_3_0/source/rpc_server/srv_srvsvc_nt.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_server/srv_srvsvc_nt.c 2007-02-01 16:22:07 UTC (rev 21114)
+++ branches/SAMBA_3_0/source/rpc_server/srv_srvsvc_nt.c 2007-02-01 19:29:07 UTC (rev 21115)
@@ -1219,7 +1219,7 @@
if ((strequal(session_list[snum].username, r->in.user) || r->in.user[0] == '\0' ) &&
strequal(session_list[snum].remote_machine, machine)) {
- if (message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False))
+ if (NT_STATUS_IS_OK(message_send_pid(pid_to_procid(session_list[snum].pid), MSG_SHUTDOWN, NULL, 0, False)))
status = WERR_OK;
}
}
Modified: branches/SAMBA_3_0/source/smbd/open.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/open.c 2007-02-01 16:22:07 UTC (rev 21114)
+++ branches/SAMBA_3_0/source/smbd/open.c 2007-02-01 19:29:07 UTC (rev 21115)
@@ -652,7 +652,7 @@
BOOL valid_entry = False;
BOOL delay_it = False;
BOOL have_level2 = False;
- BOOL ret;
+ NTSTATUS status;
char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE];
if (oplock_request & INTERNAL_OPEN_ONLY) {
@@ -740,10 +740,11 @@
SSVAL(msg,6,exclusive->op_type | FORCE_OPLOCK_BREAK_TO_NONE);
}
- ret = message_send_pid(exclusive->pid, MSG_SMB_BREAK_REQUEST,
- msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True);
- if (!ret) {
- DEBUG(3, ("Could not send oplock break message\n"));
+ status = message_send_pid(exclusive->pid, MSG_SMB_BREAK_REQUEST,
+ msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(3, ("Could not send oplock break message: %s\n",
+ nt_errstr(status)));
}
return True;
Modified: branches/SAMBA_3_0/source/utils/smbcontrol.c
===================================================================
--- branches/SAMBA_3_0/source/utils/smbcontrol.c 2007-02-01 16:22:07 UTC (rev 21114)
+++ branches/SAMBA_3_0/source/utils/smbcontrol.c 2007-02-01 19:29:07 UTC (rev 21115)
@@ -59,7 +59,8 @@
return False;
if (procid_to_pid(&pid) != 0)
- return message_send_pid(pid, msg_type, buf, len, duplicates);
+ return NT_STATUS_IS_OK(message_send_pid(pid, msg_type, buf, len,
+ duplicates));
tdb = tdb_open_log(lock_path("connections.tdb"), 0,
TDB_DEFAULT, O_RDWR, 0);
More information about the samba-cvs
mailing list