Changeset 3272 in orxonox.OLD for orxonox/branches/updater
- Timestamp:
- Dec 24, 2004, 8:41:18 PM (20 years ago)
- Location:
- orxonox/branches/updater
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/updater/configure
r3271 r3272 6969 6969 6970 6970 6971 #checking for pthread libs 6972 # AC_CHECK_LIB([pthread], [main], FOUND_pthread=yes) 6973 # if test "$FOUND_pthread" = "yes" ; then 6974 # LIBS="$LIBS -lpthread" 6975 # fi 6971 checking for pthread libs 6972 echo "$as_me:$LINENO: checking for main in -lpthread" >&5 6973 echo $ECHO_N "checking for main in -lpthread... $ECHO_C" >&6 6974 if test "${ac_cv_lib_pthread_main+set}" = set; then 6975 echo $ECHO_N "(cached) $ECHO_C" >&6 6976 else 6977 ac_check_lib_save_LIBS=$LIBS 6978 LIBS="-lpthread $LIBS" 6979 cat >conftest.$ac_ext <<_ACEOF 6980 /* confdefs.h. */ 6981 _ACEOF 6982 cat confdefs.h >>conftest.$ac_ext 6983 cat >>conftest.$ac_ext <<_ACEOF 6984 /* end confdefs.h. */ 6985 6986 6987 int 6988 main () 6989 { 6990 main (); 6991 ; 6992 return 0; 6993 } 6994 _ACEOF 6995 rm -f conftest.$ac_objext conftest$ac_exeext 6996 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 6997 (eval $ac_link) 2>conftest.er1 6998 ac_status=$? 6999 grep -v '^ *+' conftest.er1 >conftest.err 7000 rm -f conftest.er1 7001 cat conftest.err >&5 7002 echo "$as_me:$LINENO: \$? = $ac_status" >&5 7003 (exit $ac_status); } && 7004 { ac_try='test -z "$ac_c_werror_flag" 7005 || test ! -s conftest.err' 7006 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 7007 (eval $ac_try) 2>&5 7008 ac_status=$? 7009 echo "$as_me:$LINENO: \$? = $ac_status" >&5 7010 (exit $ac_status); }; } && 7011 { ac_try='test -s conftest$ac_exeext' 7012 { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 7013 (eval $ac_try) 2>&5 7014 ac_status=$? 7015 echo "$as_me:$LINENO: \$? = $ac_status" >&5 7016 (exit $ac_status); }; }; then 7017 ac_cv_lib_pthread_main=yes 7018 else 7019 echo "$as_me: failed program was:" >&5 7020 sed 's/^/| /' conftest.$ac_ext >&5 7021 7022 ac_cv_lib_pthread_main=no 7023 fi 7024 rm -f conftest.err conftest.$ac_objext \ 7025 conftest$ac_exeext conftest.$ac_ext 7026 LIBS=$ac_check_lib_save_LIBS 7027 fi 7028 echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_main" >&5 7029 echo "${ECHO_T}$ac_cv_lib_pthread_main" >&6 7030 if test $ac_cv_lib_pthread_main = yes; then 7031 FOUND_pthread=yes 7032 fi 7033 7034 if test "$FOUND_pthread" = "yes" ; then 7035 LIBS="$LIBS -lpthread" 7036 fi 6976 7037 6977 7038 -
orxonox/branches/updater/configure.ac
r3271 r3272 403 403 404 404 405 #checking for pthread libs406 #AC_CHECK_LIB([pthread], [main], FOUND_pthread=yes)407 #if test "$FOUND_pthread" = "yes" ; then408 #LIBS="$LIBS -lpthread"409 #fi405 checking for pthread libs 406 AC_CHECK_LIB([pthread], [main], FOUND_pthread=yes) 407 if test "$FOUND_pthread" = "yes" ; then 408 LIBS="$LIBS -lpthread" 409 fi 410 410 411 411 -
orxonox/branches/updater/src/gui/orxonox_gui_update.cc
r3271 r3272 201 201 202 202 CURL* OrxonoxGuiUpdate::curlHandle = NULL; 203 GThread* OrxonoxGuiUpdate::downloadThreadID = NULL; 203 pthread_t* OrxonoxGuiUpdate::downloadThreadID = new pthread_t; 204 bool OrxonoxGuiUpdate::isDownloading = false; 204 205 205 206 void* OrxonoxGuiUpdate::download (void* fileInfo) … … 209 210 FileInfo* info = (FileInfo*)fileInfo; 210 211 CURLcode res; 211 FILE* outfile;212 212 curlHandle = curl_easy_init(); 213 213 char* fileOnNet = new char [strlen(info->webRoot)+strlen(info->fileName)+1]; … … 217 217 strcpy (fileOnDisk, info->localRoot); 218 218 strcat (fileOnDisk, info->fileName); 219 219 pthread_t test; 220 220 if(curlHandle) 221 221 { 222 222 223 outfile = fopen(fileOnDisk, "w");223 info->fileHandle = fopen(fileOnDisk, "w"); 224 224 225 225 curl_easy_setopt(curlHandle, CURLOPT_URL, fileOnNet); 226 curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, outfile);226 curl_easy_setopt(curlHandle, CURLOPT_WRITEDATA, info->fileHandle); 227 227 curl_easy_setopt(curlHandle, CURLOPT_WRITEFUNCTION, curlWriteFunc); 228 228 curl_easy_setopt(curlHandle, CURLOPT_READFUNCTION, curlReadFunc); … … 231 231 curl_easy_setopt(curlHandle, CURLOPT_PROGRESSDATA, info->Bar); 232 232 233 if (! downloadThreadID)233 if (!isDownloading) 234 234 { 235 235 //! \todo check if threads really were created. 236 downloadThreadID = g_thread_create(&downloadThread, info, TRUE, NULL); 237 238 g_thread_create(&downloadThreadFinished, outfile, TRUE, NULL); 236 pthread_create(downloadThreadID, NULL, downloadThread, info); 237 // else 238 // PRINTF(1)("thread already in use\n"); 239 // res = curl_easy_perform(curlHandle); 240 241 // fclose(outfile); 239 242 } 240 else241 PRINTF(1)("thread already in use\n");242 // res = curl_easy_perform(curlHandle);243 244 // fclose(outfile);245 243 } 246 // downloadThreadID = NULL;247 244 return NULL; 248 245 } 249 246 void* OrxonoxGuiUpdate::downloadThread(void* fileInfo) 250 247 { 251 // gdk_threads_enter(); 248 isDownloading = true; 249 250 FileInfo* info = (FileInfo*)fileInfo; 252 251 curl_easy_perform(curlHandle); 253 252 if (curlHandle) 254 253 curl_easy_cleanup(curlHandle); 255 gdk_threads_leave(); 256 downloadThreadID = NULL; 257 // g_thread_exit (NULL); 258 } 259 260 void* OrxonoxGuiUpdate::downloadThreadFinished(void* outfile) 261 { 262 g_thread_join(downloadThreadID); 254 255 pthread_join(*downloadThreadID, NULL); 263 256 PRINTF(3)("Closing the downloaded file.\n"); 264 fclose((FILE*)outfile); 265 } 257 fclose(info->fileHandle); 258 259 isDownloading = false; 260 } 261 266 262 267 263 #ifdef HAVE_GTK2 -
orxonox/branches/updater/src/gui/orxonox_gui_update.h
r3271 r3272 14 14 #include <curl/easy.h> 15 15 #endif /* HAVE_CURL */ 16 #include <pthread.h> 16 17 using namespace std; 17 18 … … 50 51 char* webRoot; //!< The Root of the File on The Web 51 52 char* localRoot; //!< The Root directory to put the files on the local disk. 53 FILE* fileHandle; //!< A fileHandler. 52 54 53 55 ProgressBar* Bar; //!< The ProgressBar, that sould be updated. … … 62 64 static gint cancelDownload(GtkWidget* w, GdkEventKey* event, void* bar); 63 65 #endif /* HAVE_GTK2 */ 64 static GThread* downloadThreadID; 66 static pthread_t* downloadThreadID; 67 static bool isDownloading; 68 65 69 static void* download (void* fileInfo); 66 70 static void* downloadThread (void* fileInfo);
Note: See TracChangeset
for help on using the changeset viewer.