struct msg_all {
int msg_type;
+ uint32 msg_flag;
const void *buf;
size_t len;
BOOL duplicates;
- int n_sent;
+ int n_sent;
};
/****************************************************************************
if (crec.cnum != -1)
return 0;
- /* if the msg send fails because the pid was not found (i.e. smbd died),
+ /* Don't send if the receiver hasn't registered an interest. */
+
+ if(!(crec.bcast_msg_flags & msg_all->msg_flag))
+ return 0;
+
+ /* 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)) {
- /* if the pid was not found delete the entry from connections.tdb */
+ /* If the pid was not found delete the entry from connections.tdb */
+
if (errno == ESRCH) {
DEBUG(2,("pid %u doesn't exist - deleting connections %d [%s]\n",
(unsigned int)crec.pid, crec.cnum, crec.name));
struct msg_all msg_all;
msg_all.msg_type = msg_type;
+ if (msg_type < 1000)
+ msg_all.msg_flag = FLAG_MSG_GENERAL;
+ else if (msg_type > 1000 && msg_type < 2000)
+ msg_all.msg_flag = FLAG_MSG_NMBD;
+ else if (msg_type > 2000 && msg_type < 3000)
+ msg_all.msg_flag = FLAG_MSG_PRINTING;
+ else if (msg_type > 3000 && msg_type < 4000)
+ msg_all.msg_flag = FLAG_MSG_SMBD;
+ else
+ return False;
+
msg_all.buf = buf;
msg_all.len = len;
msg_all.duplicates = duplicates_allowed;
Store a job structure back to the database.
****************************************************************************/
-static BOOL pjob_store(int snum, uint32 jobid, struct printjob *pjob)
+static BOOL pjob_store(int snum, uint32 jobid, struct printjob *pjob, BOOL donotify)
{
TDB_DATA old_data, new_data;
BOOL ret;
/* Send notify updates for what has changed */
- if (ret && (old_data.dsize == 0 || old_data.dsize == sizeof(*pjob))) {
+ if (donotify && ret && (old_data.dsize == 0 || old_data.dsize == sizeof(*pjob))) {
pjob_store_notify(
snum, jobid, (struct printjob *)old_data.dptr,
(struct printjob *)new_data.dptr);
fstrcpy(pj.user, q->fs_user);
fstrcpy(pj.queuename, lp_const_servicename(snum));
- pjob_store(snum, jobid, &pj);
+ pjob_store(snum, jobid, &pj, True);
}
pjob->sysjob = queue[i].job;
pjob->status = queue[i].status;
- pjob_store(snum, jobid, pjob);
+ pjob_store(snum, jobid, pjob, True);
}
/* now delete any queued entries that don't appear in the
return False;
fstrcpy(pjob->jobname, name);
- return pjob_store(snum, jobid, pjob);
+ return pjob_store(snum, jobid, pjob, True);
}
/****************************************************************************
/* Set the tdb entry to be deleting. */
pjob->status = LPQ_DELETING;
- pjob_store(snum, jobid, pjob);
+ pjob_store(snum, jobid, pjob, True);
if (pjob->spooled && pjob->sysjob != -1)
result = (*(current_printif->job_delete))(snum, pjob);
return_code = write(pjob->fd, buf, size);
if (return_code>0) {
pjob->size += size;
- pjob_store(snum, jobid, pjob);
+ pjob_store(snum, jobid, pjob, True);
}
return return_code;
}
return len;
}
+#if 0 /* JRATEST */
/****************************************************************************
Determine the number of jobs in all queues. This is very expensive. Don't
call ! JRA.
}
return total_jobs;
}
+#endif /* JRATEST */
/***************************************************************************
Start spooling a job - return the jobid.
return (uint32)-1;
}
+#if 0 /* JRATEST */
/* Insure the maximum print jobs in the system is not violated */
if (lp_totalprintjobs() && get_total_jobs() > lp_totalprintjobs()) {
DEBUG(3, ("print_job_start: number of jobs (%d) larger than max printjobs per system (%d).\n",
errno = ENOSPC;
return (uint32)-1;
}
+#endif /* JRATEST */
/* create the database entry */
ZERO_STRUCT(pjob);
if (!print_job_exists(snum, jobid))
break;
}
- if (jobid == next_jobid || !pjob_store(snum, jobid, &pjob)) {
+ if (jobid == next_jobid || !pjob_store(snum, jobid, &pjob, False)) {
DEBUG(3, ("print_job_start: either jobid (%d)==next_jobid(%d) or pjob_store failed.\n",
jobid, next_jobid ));
jobid = -1;
goto fail;
}
+ /* We've finished with the INFO/nextjob lock. */
+ tdb_unlock_bystring(pdb->tdb, "INFO/nextjob");
+
/* we have a job entry - now create the spool file */
slprintf(pjob.filename, sizeof(pjob.filename)-1, "%s/%s%.8u.XXXXXX",
path, PRINT_SPOOL_PREFIX, (unsigned int)jobid);
goto fail;
}
- pjob_store(snum, jobid, &pjob);
+ pjob_store(snum, jobid, &pjob, False);
- tdb_unlock_bystring(pdb->tdb, "INFO/nextjob");
release_print_db(pdb);
/*
return;
pjob->page_count++;
- pjob_store(snum, jobid, pjob);
+ pjob_store(snum, jobid, pjob, True);
}
/****************************************************************************
pjob->spooled = True;
pjob->status = LPQ_QUEUED;
- pjob_store(snum, jobid, pjob);
+ pjob_store(snum, jobid, pjob, True);
/* make sure the database is up to date */
if (print_cache_expired(snum))
TDB_CONTEXT *conn_tdb_ctx(void)
{
- if (!tdb) {
+ if (!tdb)
tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
O_RDWR | O_CREAT, 0644);
- }
return tdb;
}
struct connections_key key;
TDB_DATA kbuf;
- if (!tdb) return False;
+ if (!tdb)
+ return False;
DEBUG(3,("Yielding connection to %s\n",name));
Claim an entry in the connections database.
****************************************************************************/
-BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOOL Clear)
+BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOOL Clear, uint32 msg_flags)
{
struct connections_key key;
struct connections_data crec;
TDB_DATA kbuf, dbuf;
- if (!tdb) {
+ if (!tdb)
tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
O_RDWR | O_CREAT, 0644);
- }
+
if (!tdb)
return False;
lp_servicename(SNUM(conn)),sizeof(crec.name)-1);
}
crec.start = time(NULL);
+ crec.bcast_msg_flags = msg_flags;
StrnCpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine)-1);
StrnCpy(crec.addr,conn?conn->client_address:client_addr(),sizeof(crec.addr)-1);