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;
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 );
}
* 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)
{
}
}
- 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;
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;
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;