| 410 | */ |
| 411 | |
| 412 | int /* O - 1 if partial close, 0 if fully closed */ |
| 413 | cupsdCloseClient(cupsd_client_t *con) /* I - Client to close */ |
| 414 | { |
| 415 | int partial; /* Do partial close for SSL? */ |
| 416 | |
| 417 | |
| 418 | cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing connection."); |
| 419 | |
| 420 | /* |
| 421 | * Flush pending writes before closing... |
| 422 | */ |
| 423 | |
| 424 | httpFlushWrite(con->http); |
| 425 | |
| 426 | partial = 0; |
| 427 | |
| 428 | if (con->pipe_pid != 0) |
| 429 | { |
| 430 | /* |
| 431 | * Stop any CGI process... |
| 432 | */ |
| 433 | |
| 434 | cupsdEndProcess(con->pipe_pid, 1); |
| 435 | con->pipe_pid = 0; |
| 436 | } |
| 437 | |
| 438 | if (con->file >= 0) |
| 439 | { |
| 440 | cupsdRemoveSelect(con->file); |
| 441 | |
| 442 | close(con->file); |
| 443 | con->file = -1; |
| 444 | } |
| 445 | |
| 446 | if (con->bg_pending) |
| 447 | { |
| 448 | /* |
| 449 | * Don't close connection when there is a background thread pending |
| 450 | */ |
| 451 | partial = 1; |
| 452 | } |
| 453 | |
| 454 | /* |
| 455 | * Close the socket and clear the file from the input set for select()... |
| 456 | */ |
| 457 | |
| 458 | if (httpGetFd(con->http) >= 0) |
| 459 | { |
| 460 | cupsArrayRemove(ActiveClients, con); |
| 461 | cupsdSetBusyState(0); |
| 462 | |
| 463 | #ifdef HAVE_TLS |
| 464 | /* |
| 465 | * Shutdown encryption as needed... |
| 466 | */ |
| 467 | |
| 468 | if (httpIsEncrypted(con->http)) |
| 469 | partial = 1; |
no test coverage detected