From: <enl...@li...> - 2002-02-21 00:08:29
|
Enlightenment CVS committal Author : gilbertt Project : misc Module : camE Dir : misc/camE Modified Files: webcam.c Log Message: Code submission from missen <mi...@mi...> Adds ftp keepalive option, which keeps the ftp connection open, instead of reopening it for each shot. I'm not sure if this will handle having an ftp session timed out, or disconnected very gracefully, so please test. =================================================================== RCS file: /cvsroot/enlightenment/misc/camE/webcam.c,v retrieving revision 1.50 retrieving revision 1.51 diff -u -3 -r1.50 -r1.51 --- webcam.c 7 Sep 2001 20:58:06 -0000 1.50 +++ webcam.c 21 Feb 2002 00:07:58 -0000 1.51 @@ -52,6 +52,7 @@ pid_t childpid = 0; int ftp_passive = 1; int ftp_do = 1; +int ftp_keepalive = 1; char *scp_target = NULL; char *grab_device = "/dev/video0"; char *grab_text = ""; /* strftime */ @@ -127,6 +128,9 @@ int delay_correct = 0; int reinit_device = 0; +int connections = 0; +CURL *curl_handle = NULL; + struct video_picture cam_pic; /* these work for v4l only, not v4l2 */ @@ -742,7 +746,6 @@ char buf[2096]; FILE *infile; CURLcode ret; - CURL *curl_handle; struct stat st; struct curl_slist *post_commands = NULL; char *passwd_string, *url_string; @@ -763,7 +766,10 @@ post_commands = curl_slist_append(post_commands, buf); /* init the curl session */ - curl_handle = curl_easy_init(); + if(connections < 1) { + curl_handle = curl_easy_init(); + connections++; + } curl_easy_setopt(curl_handle, CURLOPT_INFILE, infile); curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE, st.st_size); @@ -904,8 +910,11 @@ } /* cleanup curl stuff */ - curl_easy_cleanup(curl_handle); - curl_slist_free_all(post_commands); + if(!ftp_keepalive) { + curl_easy_cleanup(curl_handle); + curl_slist_free_all(post_commands); + connections--; + } free(url_string); free(passwd_string); fclose(infile); @@ -1080,6 +1089,8 @@ ftp_debug = i; if (-1 != (i = cfg_get_int("ftp", "do"))) ftp_do = i; + if (-1 != (i = cfg_get_int("ftp", "keepalive"))) + ftp_keepalive = i; if (-1 != (i = cfg_get_int("ftp", "timeout"))) ftp_timeout = i; if (NULL != (val = cfg_get_str("ftp", "interface"))) @@ -1358,6 +1369,7 @@ /* blockfile was just created */ log("uploading offline image\n"); offline_done = do_upload(offline_image); + log("OFFLINE\n"); } new_delay = grab_delay; if (just_shot && upload_successful) |