]> arthur.barton.de Git - netatalk.git/commitdiff
Remove adouble refcounting, support calling ad_open more then once
authorFrank Lahm <franklahm@googlemail.com>
Mon, 20 Dec 2010 14:05:21 +0000 (15:05 +0100)
committerFrank Lahm <franklahm@googlemail.com>
Mon, 20 Dec 2010 14:05:21 +0000 (15:05 +0100)
etc/afpd/ofork.c
include/atalk/adouble.h
libatalk/adouble/ad_open.c

index f5f8a38de8d7fff65a380ac83674fe9c755c190a..c19c4528e6e3ef68d37e4c19440cb251e00ccb29 100644 (file)
@@ -225,10 +225,6 @@ of_alloc(struct vol *vol,
             return NULL;
         }
         strlcpy( ad->ad_m_name, path, ad->ad_m_namelen);
-    } else {
-        /* Increase the refcount on this struct adouble. This is
-           decremented again in oforc_dealloc. */
-        ad->ad_refcount++;
     }
 
     of->of_ad = ad;
@@ -400,16 +396,7 @@ void of_dealloc( struct ofork *of)
 
     of_unhash(of);
     oforks[ of->of_refnum % nforks ] = NULL;
-
-    /* decrease refcount */
-    of->of_ad->ad_refcount--;
-
-    if ( of->of_ad->ad_refcount <= 0) {
-        free( of->of_ad->ad_m_name );
-        free( of->of_ad);
-    } else {/* someone's still using it. just free this user's locks */
-        ad_unlock(of->of_ad, of->of_refnum);
-    }
+    ad_unlock(of->of_ad, of->of_refnum);
 
     free( of );
 }
index 20ce9a221e3fd0d73c097af165e2e0543dec682d..bd668ed21ba15341bcfa0649799c612f5cc0ca4a 100644 (file)
@@ -193,7 +193,6 @@ struct adouble {
     int                 ad_adflags;  /* ad_open flags adflags like ADFLAGS_DIR */
     unsigned int        ad_inited;
     int                 ad_options;
-    int                 ad_refcount; /* used in afpd/ofork.c */
     void                *ad_resforkbuf;  /* buffer for AD_VERSION_EA ressource fork */
     size_t              ad_resforkbufsize; /* size of ad_resforkbuf */
     off_t               ad_rlen;     /* ressource fork len with AFP 3.0
index 37d42fe1e1753bffc189d8fc05a4953639a06043..eb4e177572ff43a74e4fa521736f1613bd6ee130 100644 (file)
@@ -1048,20 +1048,11 @@ static const char *oflags2logstr(int oflags)
  *                ADFLAGS_RDONLY:    open read only \n
  *                ADFLAGS_OPENFORKS: check for open forks from other processes
  *
- * @param oflags  flags passed through to open syscall: \n
- *                O_RDONLY: *** FIXME *** \n
- *                O_RDWR: *** FIXME *** \n
- *                O_CREAT: create fork \n
- *                O_EXCL: fail if exists with O_CREAT
- *
+ * @param oflags  flags passed through to open syscall
  * @param mode    passed to open with O_CREAT
  * @param ad      pointer to struct adouble
  *
- * @returns 0 on success
- *
- * @note It's not possible to open the header file O_RDONLY -- the read
- *       will fail and return an error. this refcounts things now.\n
- *       metadata(ressource)-fork only gets created with O_CREAT.
+ * @returns 0 on success, any other value indicates an error
  */
 int ad_open(const char *path, int adflags, int oflags, int mode, struct adouble  *ad)
 {
@@ -1080,9 +1071,7 @@ int ad_open(const char *path, int adflags, int oflags, int mode, struct adouble
         }
     }
 
-    ad->ad_refcount++;
-
-    if ((adflags & ADFLAGS_DF)) {
+    if ((adflags & ADFLAGS_DF) && !(ad->ad_adflags & ADFLAGS_DF)) {
         if (ad_open_df(path, adflags, oflags, mode, ad) != 0) {
             ret = -1;
             goto exit;
@@ -1090,7 +1079,7 @@ int ad_open(const char *path, int adflags, int oflags, int mode, struct adouble
         ad->ad_adflags |= ADFLAGS_DF;
     }
 
-    if ((adflags & ADFLAGS_HF)) {
+    if ((adflags & ADFLAGS_HF) && !(ad->ad_adflags & ADFLAGS_HF)) {
         if (ad_open_hf(path, adflags, oflags, mode, ad) != 0) {
             ret = -1;
             goto exit;
@@ -1098,7 +1087,7 @@ int ad_open(const char *path, int adflags, int oflags, int mode, struct adouble
         ad->ad_adflags |= ADFLAGS_HF;
     }
 
-    if ((adflags & ADFLAGS_RF)) {
+    if ((adflags & ADFLAGS_RF) && !(ad->ad_adflags & ADFLAGS_RF)) {
         if (ad_open_rf(path, adflags, oflags, mode, ad) != 0) {
             ret = -1;
             goto exit;