searching_now = false;
searchListener = NULL;
+ int i;
+
+ for (i=0; i < NUM_OF_THREADS; i++) {
+ threads[i] = 0;
+ }
+
search_list.push_back(this);
}
bool Search::start()
{
MSF_DBG("Search::start()");
- if (searching_now == false) {
- if (search_ref_count == 0) {
- search_ref_count++;
-
- searching_now = true;
+ search_ref_count++;
+ searching_now = true;
- startDiscovery();
- } else {
- search_ref_count++;
-
- searching_now = true;
-
- if (searchListener != NULL) {
- searchListener->onStart();
- }
- }
- }
+ startDiscovery();
return true;
}
MSF_DBG("search stop");
if (searching_now == true) {
search_ref_count--;
- searching_now = false;
- if (search_ref_count == 0) {
- stopDiscovery();
- } else {
- if (searchListener != NULL) {
- searchListener->onStop();
- }
- }
+ stopDiscovery();
+ searching_now = false;
}
return true;
provider_mdns.start();
- ret = pthread_create(&threads[MSFD_THREAD_NUMBER], NULL, pt_startMSFD, NULL);
- if (ret == -1) {
- MSF_DBG("MSFD thread create failed");
+ if ( threads[MSFD_THREAD_NUMBER] == 0 ) {
+ ret = pthread_create(&threads[MSFD_THREAD_NUMBER], NULL, pt_startMSFD, NULL);
+ if (ret == -1) {
+ MSF_DBG("MSFD thread create failed");
+ }
}
- ret = pthread_create(&threads[UPDATE_THREAD_NUMBER], NULL, pt_update_alivemap, NULL);
- if (ret == -1) {
- MSF_DBG("update thread create failed");
+ if ( threads[UPDATE_THREAD_NUMBER] == 0 ) {
+ ret = pthread_create(&threads[UPDATE_THREAD_NUMBER], NULL, pt_update_alivemap, NULL);
+ if (ret == -1) {
+ MSF_DBG("update thread create failed");
+ }
}
onStart();
pthread_cancel(threads[UPDATE_THREAD_NUMBER]);
pthread_join(threads[UPDATE_THREAD_NUMBER], NULL);
+ threads[MSFD_THREAD_NUMBER] = 0;
+ threads[UPDATE_THREAD_NUMBER] = 0;
+
MSF_DBG("MSFD thread joined");
MSF_DBG("update alivemap thread joined");
}