r10656: BIG merge from trunk. Features not copied over
[tprouty/samba.git] / source3 / smbd / connection.c
index 5547309a818591d24401bd36889640b9ba8a199d..07d3181144f7dfd53c70fdbacdf3cd35c22c21ab 100644 (file)
@@ -38,9 +38,17 @@ TDB_CONTEXT *conn_tdb_ctx(void)
 static void make_conn_key(connection_struct *conn, const char *name, TDB_DATA *pkbuf, struct connections_key *pkey)
 {
        ZERO_STRUCTP(pkey);
-       pkey->pid = sys_getpid();
+       pkey->pid = procid_self();
        pkey->cnum = conn?conn->cnum:-1;
        fstrcpy(pkey->name, name);
+#ifdef DEVELOPER
+       /* valgrind fixer... */
+       {
+               size_t sl = strlen(pkey->name);
+               if (sizeof(fstring)-sl)
+                       memset(&pkey->name[sl], '\0', sizeof(fstring)-sl);
+       }
+#endif
 
        pkbuf->dptr = (char *)pkey;
        pkbuf->dsize = sizeof(*pkey);
@@ -99,8 +107,8 @@ static int count_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *u
        /* If the pid was not found delete the entry from connections.tdb */
 
        if (cs->Clear && !process_exists(crec.pid) && (errno == ESRCH)) {
-               DEBUG(2,("pid %u doesn't exist - deleting connections %d [%s]\n",
-                       (unsigned int)crec.pid, crec.cnum, crec.name));
+               DEBUG(2,("pid %s doesn't exist - deleting connections %d [%s]\n",
+                       procid_str_static(&crec.pid), crec.cnum, crec.name));
                if (tdb_delete(the_tdb, kbuf) != 0)
                        DEBUG(0,("count_fn: tdb_delete failed with error %s\n", tdb_errorstr(tdb) ));
                return 0;
@@ -166,7 +174,7 @@ BOOL claim_connection(connection_struct *conn, const char *name,int max_connecti
        /* fill in the crec */
        ZERO_STRUCT(crec);
        crec.magic = 0x280267;
-       crec.pid = sys_getpid();
+       crec.pid = procid_self();
        crec.cnum = conn?conn->cnum:-1;
        if (conn) {
                crec.uid = conn->uid;
@@ -209,19 +217,19 @@ BOOL register_message_flags(BOOL doreg, uint32 msg_flags)
 
         dbuf = tdb_fetch(tdb, kbuf);
         if (!dbuf.dptr) {
-               DEBUG(0,("register_message_flags: tdb_fetch failed\n"));
+               DEBUG(0,("register_message_flags: tdb_fetch failed: %s\n",
+                       tdb_errorstr(tdb)));
                return False;
        }
 
        pcrec = (struct connections_data *)dbuf.dptr;
-       pcrec->bcast_msg_flags = msg_flags;
        if (doreg)
                pcrec->bcast_msg_flags |= msg_flags;
        else
                pcrec->bcast_msg_flags &= ~msg_flags;
 
        if (tdb_store(tdb, kbuf, dbuf, TDB_REPLACE) != 0) {
-               DEBUG(0,("register_message_flags: tdb_store failed with error %s.\n",
+               DEBUG(0,("register_message_flags: tdb_store failed: %s.\n",
                        tdb_errorstr(tdb) ));
                SAFE_FREE(dbuf.dptr);
                return False;