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

Function cupsdAddSelect

scheduler/select.c:234–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232 */
233
234int /* O - 1 on success, 0 on error */
235cupsdAddSelect(int fd, /* I - File descriptor */
236 cupsd_selfunc_t read_cb, /* I - Read callback */
237 cupsd_selfunc_t write_cb,/* I - Write callback */
238 void *data) /* I - Data to pass to callback */
239{
240 _cupsd_fd_t *fdptr; /* File descriptor record */
241#ifdef HAVE_EPOLL
242 int added; /* 1 if added, 0 if modified */
243#endif /* HAVE_EPOLL */
244
245
246 /*
247 * Range check input...
248 */
249
250 cupsdLogMessage(CUPSD_LOG_DEBUG2,
251 "cupsdAddSelect(fd=%d, read_cb=%p, write_cb=%p, data=%p)",
252 fd, read_cb, write_cb, data);
253
254 if (fd < 0)
255 return (0);
256
257 /*
258 * See if this FD has already been added...
259 */
260
261 if ((fdptr = find_fd(fd)) == NULL)
262 {
263 /*
264 * No, add a new entry...
265 */
266
267 if ((fdptr = calloc(1, sizeof(_cupsd_fd_t))) == NULL)
268 return (0);
269
270 fdptr->fd = fd;
271 fdptr->use = 1;
272
273 if (!cupsArrayAdd(cupsd_fds, fdptr))
274 {
275 cupsdLogMessage(CUPSD_LOG_EMERG, "Unable to add fd %d to array!", fd);
276 free(fdptr);
277 return (0);
278 }
279
280#ifdef HAVE_EPOLL
281 added = 1;
282 }
283 else
284 added = 0;
285#else
286 }
287#endif /* HAVE_EPOLL */
288
289#ifdef HAVE_KQUEUE

Callers 13

cupsd_start_notifierFunction · 0.85
cupsdAcceptClientFunction · 0.85
cupsdCloseClientFunction · 0.85
cupsdSendCommandFunction · 0.85
cupsdWriteClientFunction · 0.85
write_fileFunction · 0.85
write_pipeFunction · 0.85
cupsdStartSystemMonitorFunction · 0.85
cupsdStartServerFunction · 0.85
send_responseFunction · 0.85
cupsdContinueJobFunction · 0.85
cupsdStartBrowsingFunction · 0.85

Calls 3

cupsdLogMessageFunction · 0.85
find_fdFunction · 0.85
cupsArrayAddFunction · 0.85

Tested by

no test coverage detected