Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37732185
en ru br
Репозитории ALT
S:0.8.7-alt4
5.1: 0.8.7-alt2.M51.1
4.1: 0.8.5-alt2
4.0: 0.8.5-alt2
3.0:
+backports:0.8.3-alt1.M30.1
www.altlinux.org/Changes

Группа :: Система/Ядро и оборудование
Пакет: fuse-smb

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: fuse-smb-CacheThreadRemove.patch
Скачать


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 <libsmbclient.h>
-#include <pthread.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -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<num_threads; i++)
-    {
-        int rc = pthread_join(threads[i], NULL);
-        if (rc)
-        {
-            fprintf(stderr, "Error while joining thread, errorcode: %d\n", rc);
-            exit(-1);
-        }
-    }
-    free(threads);
-
     sl_casesort(cache);
     char cachefile[1024];
     char tmp_cachefile[1024];
@@ -482,9 +426,7 @@
     }
 
     for (i=0 ; i < sl_count(cache); i++)
-    {
         fprintf(fp, "%s\n", sl_item(cache, i));
-    }
     fclose(fp);
     /* Make refreshing cache file atomic */
     rename(tmp_cachefile, cachefile);
@@ -548,6 +490,7 @@
         close(STDOUT_FILENO);
         close(STDERR_FILENO);
     }
+
     SMBCCTX *ctx = fusesmb_cache_new_context(&cfg);
     cache_servers(ctx);
     smbc_free_context(ctx, 1);
@@ -558,4 +501,3 @@
     }
     exit(EXIT_SUCCESS);
 }
-
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin