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

Function httpReconnect2

cups/http.c:2342–2460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2340 */
2341
2342int /* O - 0 on success, non-zero on failure */
2343httpReconnect2(http_t *http, /* I - HTTP connection */
2344 int msec, /* I - Timeout in milliseconds */
2345 int *cancel) /* I - Pointer to "cancel" variable */
2346{
2347 http_addrlist_t *addr; /* Connected address */
2348#ifdef DEBUG
2349 http_addrlist_t *current; /* Current address */
2350 char temp[256]; /* Temporary address string */
2351#endif /* DEBUG */
2352
2353
2354 DEBUG_printf(("httpReconnect2(http=%p, msec=%d, cancel=%p)", (void *)http, msec, (void *)cancel));
2355
2356 if (!http)
2357 {
2358 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
2359 return (-1);
2360 }
2361
2362#ifdef HAVE_TLS
2363 if (http->tls)
2364 {
2365 DEBUG_puts("2httpReconnect2: Shutting down SSL/TLS...");
2366 _httpTLSStop(http);
2367 }
2368#endif /* HAVE_TLS */
2369
2370 /*
2371 * Close any previously open socket...
2372 */
2373
2374 if (http->fd >= 0)
2375 {
2376 DEBUG_printf(("2httpReconnect2: Closing socket %d...", http->fd));
2377
2378 httpAddrClose(NULL, http->fd);
2379
2380 http->fd = -1;
2381 }
2382
2383 /*
2384 * Reset all state (except fields, which may be reused)...
2385 */
2386
2387 http->state = HTTP_STATE_WAITING;
2388 http->version = HTTP_VERSION_1_1;
2389 http->keep_alive = HTTP_KEEPALIVE_OFF;
2390 memset(&http->_hostaddr, 0, sizeof(http->_hostaddr));
2391 http->data_encoding = HTTP_ENCODING_FIELDS;
2392 http->_data_remaining = 0;
2393 http->used = 0;
2394 http->data_remaining = 0;
2395 http->hostaddr = NULL;
2396 http->wused = 0;
2397
2398 /*
2399 * Connect to the server...

Callers 15

do_monitor_printer_stateFunction · 0.85
do_testFunction · 0.85
ifFunction · 0.85
mainFunction · 0.85
monitor_printerFunction · 0.85
cupsGetFdFunction · 0.85
ifFunction · 0.85
cupsPutFdFunction · 0.85
mainFunction · 0.85
ifFunction · 0.85
httpConnect2Function · 0.85
httpEncryptionFunction · 0.85

Calls 8

_cupsSetErrorFunction · 0.85
httpAddrCloseFunction · 0.85
httpAddrStringFunction · 0.85
httpAddrPortFunction · 0.85
http_set_timeoutFunction · 0.85
http_tls_upgradeFunction · 0.85
_httpTLSStopFunction · 0.70
_httpTLSStartFunction · 0.70

Tested by 3

mainFunction · 0.68
ifFunction · 0.68
monitor_printerFunction · 0.68