diff options
author | Michael Sweet <michael.r.sweet@gmail.com> | 2017-09-14 14:19:00 -0400 |
---|---|---|
committer | Michael Sweet <michael.r.sweet@gmail.com> | 2017-09-14 14:19:00 -0400 |
commit | 116c301f238c688b904713ac311eb01e4ba0264e (patch) | |
tree | 2a03f0e29daa2f23d4653ec269cdde921a043e9c /test | |
parent | b908d72cace0a011612ba312c7b1a746b74cf80d (diff) |
Detach worker threads to prevent memory leaks.
Diffstat (limited to 'test')
-rw-r--r-- | test/ippserver.c | 57 |
1 files changed, 23 insertions, 34 deletions
diff --git a/test/ippserver.c b/test/ippserver.c index 02dbdea50..38b304f80 100644 --- a/test/ippserver.c +++ b/test/ippserver.c @@ -1,7 +1,7 @@ /* * Sample IPP Everywhere server for CUPS. * - * Copyright 2010-2015 by Apple Inc. + * Copyright 2010-2017 by Apple Inc. * * These coded instructions, statements, and computer programs are the * property of Apple Inc. and are protected by Federal copyright @@ -3763,6 +3763,7 @@ ipp_print_job(_ipp_client_t *client) /* I - Client */ buffer[4096]; /* Copy buffer */ ssize_t bytes; /* Bytes read */ cups_array_t *ra; /* Attributes to send in response */ + _cups_thread_t t; /* Thread */ /* @@ -3873,7 +3874,13 @@ ipp_print_job(_ipp_client_t *client) /* I - Client */ * Process the job... */ - if (!_cupsThreadCreate((_cups_thread_func_t)process_job, job)) + t = _cupsThreadCreate((_cups_thread_func_t)process_job, job); + + if (t) + { + _cupsThreadDetach(t); + } + else { job->state = IPP_JSTATE_ABORTED; respond_ipp(client, IPP_STATUS_ERROR_INTERNAL, "Unable to process job."); @@ -4180,17 +4187,7 @@ ipp_print_uri(_ipp_client_t *client) /* I - Client */ * Process the job... */ -#if 0 - if (!_cupsThreadCreate((_cups_thread_func_t)process_job, job)) - { - job->state = IPP_JSTATE_ABORTED; - respond_ipp(client, IPP_STATUS_ERROR_INTERNAL, "Unable to process job."); - return; - } - -#else process_job(job); -#endif /* 0 */ /* * Return the job info... @@ -4382,17 +4379,7 @@ ipp_send_document(_ipp_client_t *client)/* I - Client */ * Process the job... */ -#if 0 - if (!_cupsThreadCreate((_cups_thread_func_t)process_job, job)) - { - job->state = IPP_JSTATE_ABORTED; - respond_ipp(client, IPP_STATUS_ERROR_INTERNAL, "Unable to process job."); - return; - } - -#else process_job(job); -#endif /* 0 */ /* * Return the job info... @@ -4751,17 +4738,7 @@ ipp_send_uri(_ipp_client_t *client) /* I - Client */ * Process the job... */ -#if 0 - if (!_cupsThreadCreate((_cups_thread_func_t)process_job, job)) - { - job->state = IPP_JSTATE_ABORTED; - respond_ipp(client, IPP_STATUS_ERROR_INTERNAL, "Unable to process job."); - return; - } - -#else process_job(job); -#endif /* 0 */ /* * Return the job info... @@ -6828,7 +6805,13 @@ run_printer(_ipp_printer_t *printer) /* I - Printer */ { if ((client = create_client(printer, printer->ipv4)) != NULL) { - if (!_cupsThreadCreate((_cups_thread_func_t)process_client, client)) + _cups_thread_t t = _cupsThreadCreate((_cups_thread_func_t)process_client, client); + + if (t) + { + _cupsThreadDetach(t); + } + else { perror("Unable to create client thread"); delete_client(client); @@ -6840,7 +6823,13 @@ run_printer(_ipp_printer_t *printer) /* I - Printer */ { if ((client = create_client(printer, printer->ipv6)) != NULL) { - if (!_cupsThreadCreate((_cups_thread_func_t)process_client, client)) + _cups_thread_t t = _cupsThreadCreate((_cups_thread_func_t)process_client, client); + + if (t) + { + _cupsThreadDetach(t); + } + else { perror("Unable to create client thread"); delete_client(client); |