/*
- * "$Id: subscriptions.c 5673 2006-06-16 21:04:45Z mike $"
+ * "$Id: subscriptions.c 5716 2006-07-11 17:56:57Z mike $"
*
* Subscription routines for the Common UNIX Printing System (CUPS) scheduler.
*
cupsd_subscription_t *sub; /* Current subscription */
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
+ "cupsdAddEvent(event=%s, dest=%p(%s), job=%p(%d), text=\"%s\", ...)",
+ cupsdEventName(event), dest, dest ? dest->name : "",
+ job, job ? job->id : 0, text);
+
/*
* Keep track of events with any OS-supplied notification mechanisms...
*/
ippAddInteger(temp->attrs, IPP_TAG_EVENT_NOTIFICATION, IPP_TAG_INTEGER,
"job-impressions-completed",
job->sheets ? job->sheets->values[0].integer : 0);
+ }
- /*
- * Send the notification for this subscription...
- */
+ /*
+ * Send the notification for this subscription...
+ */
- cupsd_send_notification(sub, temp);
- }
+ cupsd_send_notification(sub, temp);
}
}
ipp_state_t state; /* IPP event state */
- cupsdLogMessage(CUPSD_LOG_DEBUG,
+ cupsdLogMessage(CUPSD_LOG_DEBUG2,
"cupsd_send_notification(sub=%p(%d), event=%p(%s))\n",
sub, sub->id, event, cupsdEventName(event->event));
if (sub->recipient)
{
- if (sub->pipe < 0)
- cupsd_start_notifier(sub);
+ for (;;)
+ {
+ if (sub->pipe < 0)
+ cupsd_start_notifier(sub);
- cupsdLogMessage(CUPSD_LOG_DEBUG, "sub->pipe=%d", sub->pipe);
+ cupsdLogMessage(CUPSD_LOG_DEBUG2, "sub->pipe=%d", sub->pipe);
+
+ if (sub->pipe < 0)
+ break;
- if (sub->pipe >= 0)
- {
event->attrs->state = IPP_IDLE;
while ((state = ippWriteFile(sub->pipe, event->attrs)) != IPP_DATA)
break;
if (state == IPP_ERROR)
+ {
+ if (errno == EPIPE)
+ {
+ /*
+ * Notifier died, try restarting it...
+ */
+
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Notifier for subscription %d (%s) went away, "
+ "retrying!",
+ sub->id, sub->recipient);
+ cupsdEndProcess(sub->pid, 0);
+
+ close(sub->pipe);
+ sub->pipe = -1;
+ continue;
+ }
+
cupsdLogMessage(CUPSD_LOG_ERROR,
"Unable to send event for subscription %d (%s)!",
sub->id, sub->recipient);
+ }
+
+ /*
+ * If we get this far, break out of the loop...
+ */
+
+ break;
}
}
/*
- * End of "$Id: subscriptions.c 5673 2006-06-16 21:04:45Z mike $".
+ * End of "$Id: subscriptions.c 5716 2006-07-11 17:56:57Z mike $".
*/