From bc9c60382b226e5a75a11a99364b9b799dc2b0c2 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Tue, 5 Jul 2016 18:52:12 +0200 Subject: lib: Change invalid pid to -1 The stack used pid 0 (the scheduler) to indicate an invalid process instance, probably as a leftover from the deprecated application process instance id. Using -1 is a better solution. Fixes #16. --- src/lib/dev.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/lib/dev.c') diff --git a/src/lib/dev.c b/src/lib/dev.c index 19bc90e5..d85afc45 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -93,7 +93,7 @@ int ap_init(char * ap_name) for (i = 0; i < AP_MAX_FLOWS; ++i) { _ap_instance->flows[i].rb = NULL; _ap_instance->flows[i].port_id = -1; - _ap_instance->flows[i].api = 0; /* API_INVALID */ + _ap_instance->flows[i].api = -1; } pthread_rwlock_init(&_ap_instance->flows_lock, NULL); @@ -397,7 +397,7 @@ int flow_dealloc(int fd) _ap_instance->flows[fd].port_id = -1; shm_ap_rbuff_close(_ap_instance->flows[fd].rb); _ap_instance->flows[fd].rb = NULL; - _ap_instance->flows[fd].api = 0; + _ap_instance->flows[fd].api = -1; bmp_release(_ap_instance->fds, fd); @@ -543,7 +543,7 @@ ssize_t flow_read(int fd, void * buf, size_t count) if (_ap_instance->flows[fd].oflags & FLOW_O_NONBLOCK) { idx = shm_ap_rbuff_read_port(_ap_instance->rb, - _ap_instance->flows[fd].port_id); + _ap_instance->flows[fd].port_id); } else { /* block */ while ((idx = shm_ap_rbuff_read_port(_ap_instance->rb, -- cgit v1.2.3