summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-09-12 06:57:25 +0000
committerAndrew Tridgell <tridge@samba.org>2000-09-12 06:57:25 +0000
commitdf89b4853954b7dcc86839167760cf72af693656 (patch)
tree4ca20ea06776c4eaf527e4bcf13198cd49ee581d /source3/lib
parentf0ce4f7ae3b58f45b70598e3a44539e3e12291ce (diff)
downloadsamba-df89b4853954b7dcc86839167760cf72af693656.tar.gz
samba-df89b4853954b7dcc86839167760cf72af693656.tar.bz2
samba-df89b4853954b7dcc86839167760cf72af693656.zip
- fixed some memory leaks in the messages code
- added a MSG_PING message for performance testing. (This used to be commit e779f834dbb875669c3aa0a35b324aa13f0c8c36)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/messages.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 927cb095dd..939bf36004 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -66,6 +66,14 @@ static void sig_usr1(void)
}
/****************************************************************************
+a useful function for testing the message system
+****************************************************************************/
+void ping_message(int msg_type, pid_t src, void *buf, size_t len)
+{
+ message_send_pid(src, MSG_PONG, buf, len);
+}
+
+/****************************************************************************
Initialise the messaging functions.
****************************************************************************/
BOOL message_init(void)
@@ -83,6 +91,8 @@ BOOL message_init(void)
CatchSignal(SIGUSR1, sig_usr1);
+ message_register(MSG_PING, ping_message);
+
return True;
}
@@ -167,11 +177,11 @@ BOOL message_send_pid(pid_t pid, int msg_type, void *buf, size_t len)
memcpy(p+dbuf.dsize, &rec, sizeof(rec));
if (len > 0) memcpy(p+dbuf.dsize+sizeof(rec), buf, len);
+ free(dbuf.dptr);
dbuf.dptr = p;
dbuf.dsize += len + sizeof(rec);
tdb_store(tdb, kbuf, dbuf, TDB_REPLACE);
free(dbuf.dptr);
- free(p);
ok:
tdb_unlockchain(tdb, kbuf);
@@ -256,6 +266,7 @@ void message_dispatch(void)
dfn->fn(msg_type, src, buf, len);
}
}
+ if (buf) free(buf);
}
}
@@ -277,3 +288,19 @@ void message_register(int msg_type,
DLIST_ADD(dispatch_fns, dfn);
}
+
+/****************************************************************************
+de-register the function for a particular message type
+****************************************************************************/
+void message_deregister(int msg_type)
+{
+ struct dispatch_fns *dfn, *next;
+
+ for (dfn = dispatch_fns; dfn; dfn = next) {
+ next = dfn->next;
+ if (dfn->msg_type == msg_type) {
+ DLIST_REMOVE(dispatch_fns, dfn);
+ free(dfn);
+ }
+ }
+}