diff options
-rw-r--r-- | main.c | 3 | ||||
-rw-r--r-- | main.h | 1 | ||||
-rw-r--r-- | thread_http.c | 8 | ||||
-rw-r--r-- | thread_kinect.c | 10 |
4 files changed, 15 insertions, 7 deletions
@@ -86,6 +86,7 @@ void* start_kinect_inner(void *args_anon) { thread_kinect(args->video_fd, args->depth_fd, args->accel_fd); wg_sub(&wg, 1); running = 0; + close(httpsock); return NULL; } static @@ -140,6 +141,7 @@ void *start_http_inner(void *args_anon) { thread_http_listener(args->wg, args->video, args->depth); wg_sub(&wg, 1); running = 0; + close(httpsock); return NULL; } static @@ -167,6 +169,7 @@ static void sigint_handler(int num UNUSED) { running = 0; + close(httpsock); } int main(int argc UNUSED, char **argv UNUSED) @@ -11,6 +11,7 @@ #endif extern volatile sig_atomic_t running; +extern int httpsock; struct frame { ssize_t len; diff --git a/thread_http.c b/thread_http.c index e410239..b257131 100644 --- a/thread_http.c +++ b/thread_http.c @@ -100,6 +100,8 @@ void *start_http_connection_inner(void *arg_anon) { return NULL; } +int httpsock = 0; + static void start_http_connection(int fd) { wg_add(wg, 1); @@ -113,12 +115,14 @@ void thread_http_listener(struct wg *awg, wg = awg; video = avideo; depth = adepth; - int sock = tcp4_parse_listen("8090"); + httpsock = tcp4_parse_listen("8090"); while (running) { - int conn = accept(sock, NULL, NULL); + int conn = accept(httpsock, NULL, NULL); if (conn < 0) continue; start_http_connection(conn); } + running = 0; + close(httpsock); } diff --git a/thread_kinect.c b/thread_kinect.c index f3b5a78..fdd7f25 100644 --- a/thread_kinect.c +++ b/thread_kinect.c @@ -1,8 +1,9 @@ #include <error.h> #include <libfreenect/libfreenect.h> #include <libusb-1.0/libusb.h> -#include <stdio.h> #include <pthread.h> +#include <stdio.h> +#include <unistd.h> #include "main.h" @@ -114,8 +115,7 @@ void thread_kinect(int video_fd, int depth_fd, int accel_fd) { end: freenect_shutdown(ctx); - - if (depth_stream) fclose(depth_stream); - if (video_stream) fclose(video_stream); - if (accel_stream) fclose(accel_stream); + close(video_fd); + close(depth_fd); + close(accel_fd); } |