Project

General

Profile

audacious-3.9.patch

Add error handling of pthread_create in audacious - Zhouyang Jia, February 27, 2018 08:47

View differences:

src/audacious/signals.cc
21 21

  
22 22
#include <pthread.h>
23 23
#include <signal.h>
24
#include <errno.h>
25
#include <string.h>
24 26

  
25 27
#include <libaudcore/hook.h>
28
#include <libaudcore/runtime.h>
26 29

  
27 30
#include "main.h"
28 31

  
......
53 56
void signals_init_two ()
54 57
{
55 58
    pthread_t thread;
56
    pthread_create (& thread, nullptr, signal_thread, nullptr);
59
    if (pthread_create (& thread, nullptr, signal_thread, nullptr) != 0)
60
        AUDERR ("Can not create thread: %s!\n", strerror(errno));
57 61
}
58 62

  
59 63
#endif /* HAVE_SIGWAIT */
src/libaudcore/adder.cc
22 22

  
23 23
#include <pthread.h>
24 24
#include <stdio.h>
25
#include <errno.h>
25 26
#include <string.h>
26 27

  
27 28
#include "audstrings.h"
......
35 36
#include "tuple.h"
36 37
#include "interface.h"
37 38
#include "vfs.h"
39
#include "runtime.h"
38 40

  
39 41
// regrettably, strcmp_nocase can't be used directly as a
40 42
// callback for Index::sort due to taking a third argument;
......
361 363

  
362 364
    if (! add_thread_started || add_thread_exited)
363 365
    {
364
        pthread_create (& add_thread, nullptr, add_worker, nullptr);
366
        if (pthread_create (& add_thread, nullptr, add_worker, nullptr) != 0)
367
            AUDERR ("Can not create thread: %s!\n", strerror(errno));
365 368
        add_thread_started = true;
366 369
        add_thread_exited = false;
367 370
    }
src/libaudcore/playback.cc
39 39

  
40 40
#include <assert.h>
41 41
#include <pthread.h>
42
#include <errno.h>
43
#include <string.h>
42 44

  
43 45
#include "audstrings.h"
44 46
#include "hook.h"
......
447 449
    else
448 450
    {
449 451
        pthread_t thread;
450
        pthread_create (& thread, nullptr, playback_thread, nullptr);
452
        if (pthread_create (& thread, nullptr, playback_thread, nullptr) != 0)
453
            AUDERR ("Can not create thread: %s!\n", strerror(errno));
451 454
        pthread_detach (thread);
452 455
        pb_state.thread_running = true;
453 456
    }
src/libaudcore/vfs_async.cc
18 18
 */
19 19

  
20 20
#include <pthread.h>
21
#include <errno.h>
22
#include <string.h>
21 23

  
22 24
#include "list.h"
23 25
#include "mainloop.h"
24 26
#include "vfs.h"
25 27
#include "vfs_async.h"
28
#include "runtime.h"
26 29

  
27 30
struct QueuedData : public ListNode
28 31
{
......
87 90
EXPORT void vfs_async_file_get_contents (const char * filename, VFSConsumer cons_f, void * user)
88 91
{
89 92
    auto data = new QueuedData (filename, cons_f, user);
90
    pthread_create (& data->thread, nullptr, read_worker, data);
93
    if (pthread_create (& data->thread, nullptr, read_worker, data) != 0)
94
        AUDERR ("Can not create thread: %s!\n", strerror(errno));
91 95
}