diff -uNr fusesmb-orig-0.8.7/cache.c fusesmb-0.8.7/cache.c --- fusesmb-orig-0.8.7/cache.c 2010-01-05 09:55:02.000000000 +0200 +++ fusesmb-0.8.7/cache.c 2011-10-05 17:00:36.000000000 +0300 @@ -21,7 +21,6 @@ #endif #include -#include #include #include #include @@ -43,14 +42,12 @@ stringlist_t *cache; -pthread_mutex_t cache_mutex = PTHREAD_MUTEX_INITIALIZER; struct fusesmb_cache_opt { stringlist_t *ignore_servers; stringlist_t *ignore_workgroups; }; - config_t cfg; struct fusesmb_cache_opt opts; @@ -262,16 +259,13 @@ char tmp[len]; snprintf(tmp, len, "/%s/%s/%s", wg, sv, share_dirent->name); debug("%s", tmp); - pthread_mutex_lock(&cache_mutex); if (-1 == sl_add(cache, tmp, 1)) { - pthread_mutex_unlock(&cache_mutex); fprintf(stderr, "sl_add failed\n"); ctx->closedir(ctx, dir); //smbc_free_context(ctx, 1); return -1; } - pthread_mutex_unlock(&cache_mutex); } ctx->closedir(ctx, dir); @@ -323,8 +317,6 @@ ctx->closedir(ctx, dir); use_popen: - - nmblookup(wg, servers, ip_cache); sl_casesort(servers); @@ -377,13 +369,13 @@ hash_destroy(ip_cache); sl_free(servers); smbc_free_context(ctx, 1); + return 0; } int cache_servers(SMBCCTX *ctx) { - //SMBCCTX *ctx = fusesmb_new_context(); SMBCFILE *dir; struct smbc_dirent *workgroup_dirent; @@ -391,37 +383,18 @@ cache = sl_init(); size_t i; - dir = ctx->opendir(ctx, "smb://"); if (dir == NULL) { ctx->closedir(ctx, dir); sl_free(cache); - //smbc_free_context(ctx, 1); return -1; } - pthread_t *threads; - threads = (pthread_t *)malloc(sizeof(pthread_t)); - if (NULL == threads) - return -1; - pthread_attr_t thread_attr; - pthread_attr_init(&thread_attr); - pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_JOINABLE); - - unsigned int num_threads = 0; - while (NULL != (workgroup_dirent = ctx->readdir(ctx, dir)) ) { - if (workgroup_dirent->namelen == 0 || - workgroup_dirent->smbc_type != SMBC_WORKGROUP) - { - continue; - } - //char wg[1024]; - //strncpy(wg, workgroup_dirent->name, 1024); - char *thread_arg = strdup(workgroup_dirent->name); + if (workgroup_dirent->namelen == 0 || workgroup_dirent->smbc_type != SMBC_WORKGROUP) continue; if (opts.ignore_workgroups != NULL) { @@ -432,39 +405,10 @@ } } - if (NULL == thread_arg) - continue; - int rc; - rc = pthread_create(&threads[num_threads], - &thread_attr, workgroup_listing_thread, - (void*)thread_arg); - //workgroup_listing(ctx, cache, ip_cache, wg); - if (rc) - { - fprintf(stderr, "Failed to create thread for workgroup: %s\n", workgroup_dirent->name); - free(thread_arg); - continue; - } - num_threads++; - threads = (pthread_t *)realloc(threads, (num_threads+1)*sizeof(pthread_t)); + workgroup_listing_thread(workgroup_dirent->name); } ctx->closedir(ctx, dir); - //smbc_free_context(ctx, 1); - - pthread_attr_destroy(&thread_attr); - - for (i=0; i