Merge of print notify fixes from APPLIANCE_HEAD.
authorTim Potter <tpot@samba.org>
Fri, 2 Aug 2002 03:57:40 +0000 (03:57 +0000)
committerTim Potter <tpot@samba.org>
Fri, 2 Aug 2002 03:57:40 +0000 (03:57 +0000)
source/printing/notify.c
source/smbd/connection.c
source/utils/smbcontrol.c

index 21e28d0ca715a17af92c15a24bafe70468415b1e..1b2b7805e581d9fdb947f263636538af74d75c92 100644 (file)
@@ -65,18 +65,17 @@ again:
 
        /* Send message */
 
-       tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0);
+       tdb = conn_tdb_ctx();
 
        if (!tdb) {
                DEBUG(3, ("Failed to open connections database in send_spoolss_notify2_msg\n"));
-               return;
+               goto done;
        }
+       
+       message_send_all(tdb, MSG_PRINTER_NOTIFY2, buf, buflen, False, NULL);
 
-       message_send_all(tdb, MSG_PRINTER_NOTIFY2, buf,
-                        buflen, False, NULL);
-
+done:
        SAFE_FREE(buf);
-       tdb_close(tdb);
 }
 
 static void send_notify_field_values(const char *printer_name, uint32 type,
index c9815dbf8c0edd3b9ffc8e4ed6d8c027f633a450..b53ef9fb3fcf7e2db40ff3823bd9386ca343cd6f 100644 (file)
@@ -29,6 +29,11 @@ static TDB_CONTEXT *tdb;
 
 TDB_CONTEXT *conn_tdb_ctx(void)
 {
+       if (!tdb) {
+               tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, 
+                              O_RDWR | O_CREAT, 0644);
+       }
+
        return tdb;
 }
 
index 65519e8888f8963f42d3331abc0db2476c185b7d..300e5479e5a0667b481a36a5b87942287574862a 100644 (file)
@@ -223,6 +223,23 @@ static void register_all(void)
        message_register(MSG_POOL_USAGE, pool_usage_cb);
 }
 
+/* This guy is here so we can link printing/notify.c to the smbcontrol
+   binary without having to pull in tons of other crap. */
+
+TDB_CONTEXT *conn_tdb_ctx(void)
+{
+       static TDB_CONTEXT *tdb;
+
+       if (tdb)
+               return tdb;
+
+       tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_DEFAULT, O_RDONLY, 0);
+
+       if (!tdb)
+               DEBUG(3, ("Failed to open connections database in send_spoolss_notify2_msg\n"));
+
+       return tdb;
+}
 
 /****************************************************************************
 do command