MCPcopy Create free account
hub / github.com/OpenPrinting/cups / backendRunLoop

Function backendRunLoop

backend/runloop.c:128–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126 */
127
128ssize_t /* O - Total bytes on success, -1 on error */
129backendRunLoop(
130 int print_fd, /* I - Print file descriptor */
131 int device_fd, /* I - Device file descriptor */
132 int snmp_fd, /* I - SNMP socket or -1 if none */
133 http_addr_t *addr, /* I - Address of device */
134 int use_bc, /* I - Use back-channel? */
135 int update_state, /* I - Update printer-state-reasons? */
136 _cups_sccb_t side_cb) /* I - Side-channel callback */
137{
138 int nfds; /* Maximum file descriptor value + 1 */
139 fd_set input, /* Input set for reading */
140 output; /* Output set for writing */
141 ssize_t print_bytes, /* Print bytes read */
142 bc_bytes, /* Backchannel bytes read */
143 total_bytes, /* Total bytes written */
144 bytes; /* Bytes written */
145 int paperout; /* "Paper out" status */
146 int offline; /* "Off-line" status */
147 char print_buffer[8192], /* Print data buffer */
148 *print_ptr, /* Pointer into print data buffer */
149 bc_buffer[1024]; /* Back-channel data buffer */
150 struct timeval timeout; /* Timeout for select() */
151 time_t curtime, /* Current time */
152 snmp_update = 0;
153#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
154 struct sigaction action; /* Actions for POSIX signals */
155#endif /* HAVE_SIGACTION && !HAVE_SIGSET */
156
157
158 fprintf(stderr,
159 "DEBUG: backendRunLoop(print_fd=%d, device_fd=%d, snmp_fd=%d, "
160 "addr=%p, use_bc=%d, side_cb=%p)\n",
161 print_fd, device_fd, snmp_fd, addr, use_bc, side_cb);
162
163 /*
164 * If we are printing data from a print driver on stdin, ignore SIGTERM
165 * so that the driver can finish out any page data, e.g. to eject the
166 * current page. We only do this for stdin printing as otherwise there
167 * is no way to cancel a raw print job...
168 */
169
170 if (!print_fd)
171 {
172#ifdef HAVE_SIGSET /* Use System V signals over POSIX to avoid bugs */
173 sigset(SIGTERM, SIG_IGN);
174#elif defined(HAVE_SIGACTION)
175 memset(&action, 0, sizeof(action));
176
177 sigemptyset(&action.sa_mask);
178 action.sa_handler = SIG_IGN;
179 sigaction(SIGTERM, &action, NULL);
180#else
181 signal(SIGTERM, SIG_IGN);
182#endif /* HAVE_SIGSET */
183 }
184 else if (print_fd < 0)
185 {

Callers 4

mainFunction · 0.85
print_deviceFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 5

_cupsLangPrintFilterFunction · 0.85
cupsBackChannelWriteFunction · 0.85
_cupsLangPrintErrorFunction · 0.85
backendSNMPSuppliesFunction · 0.85
sigactionClass · 0.70

Tested by

no test coverage detected