From e0ebb46cff5d45a0bda6dd525e25ae71dec7ed57 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 20 May 2007 19:43:49 +0000 Subject: r23023: Get rid of the only caller of message_send_pid_with_timeout(). This replaces the timeouts on the individual message send calls with an overall timeout on all the calls. The timeout in message_send_pid_with_timeout() did not make much sense IMO anyway, because the tdb_fetch() for the messages_pending_for_pid was blocking in a readlock anyway, we "just" did the timeout for the write lock. This new code goes through the full wait for the write lock once and then breaks out of sending the notifies instead of running into the timeout per target. Jerry, please check this! Thanks, Volker (This used to be commit 697099f06e1aa432187f802b9c2632607e3de46e) --- source3/printing/notify.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'source3/printing/notify.c') diff --git a/source3/printing/notify.c b/source3/printing/notify.c index 1285ca23a8..37ae003783 100644 --- a/source3/printing/notify.c +++ b/source3/printing/notify.c @@ -126,6 +126,7 @@ static void print_notify_send_messages_to_printer(struct messaging_context *msg_ size_t num_pids = 0; size_t i; pid_t *pid_list = NULL; + struct timeval end_time = timeval_zero(); /* Count the space needed to send the messages. */ for (pq = notify_queue_head; pq; pq = pq->next) { @@ -177,6 +178,10 @@ static void print_notify_send_messages_to_printer(struct messaging_context *msg_ if (!print_notify_pid_list(printer, send_ctx, &num_pids, &pid_list)) return; + if (timeout != 0) { + end_time = timeval_current_ofs(timeout, 0); + } + for (i = 0; i < num_pids; i++) { unsigned int q_len = messages_pending_for_pid(pid_to_procid(pid_list[i])); if (q_len > 1000) { @@ -184,11 +189,14 @@ static void print_notify_send_messages_to_printer(struct messaging_context *msg_ printer, q_len )); continue; } - messaging_send_buf_with_timeout(msg_ctx, - pid_to_procid(pid_list[i]), - MSG_PRINTER_NOTIFY2, - (uint8 *)buf, offset, - timeout); + messaging_send_buf(msg_ctx, + pid_to_procid(pid_list[i]), + MSG_PRINTER_NOTIFY2, + (uint8 *)buf, offset); + + if ((timeout != 0) && timeval_expired(&end_time)) { + break; + } } } -- cgit