From: Ken Raeburn Date: Fri, 14 Jan 2005 03:39:24 +0000 (+0000) Subject: * cc_file.c (struct _krb5_fcc_data): Fields disk_file_lock, file_is_locked X-Git-Tag: ms-bug-test-20060525~378 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2bc5304880b85b21cfbc42e33a62afa0dfcebbea;p=krb5.git * cc_file.c (struct _krb5_fcc_data): Fields disk_file_lock, file_is_locked deleted. (krb5_fcc_open_file, krb5_fcc_close_file, dereference, krb5_fcc_resolve, krb5_fcc_generate_new, krb5_fcc_set_flags): Don't set or check them. ticket: 2874 status: open git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17034 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/ccache/ChangeLog b/src/lib/krb5/ccache/ChangeLog index b20bf53d7..63f8b3a96 100644 --- a/src/lib/krb5/ccache/ChangeLog +++ b/src/lib/krb5/ccache/ChangeLog @@ -1,3 +1,11 @@ +2005-01-13 Ken Raeburn + + * cc_file.c (struct _krb5_fcc_data): Fields disk_file_lock, + file_is_locked deleted. + (krb5_fcc_open_file, krb5_fcc_close_file, dereference, + krb5_fcc_resolve, krb5_fcc_generate_new, krb5_fcc_set_flags): + Don't set or check them. + 2005-01-11 Jeffrey Altman * cc_mslsa.c: diff --git a/src/lib/krb5/ccache/cc_file.c b/src/lib/krb5/ccache/cc_file.c index 1eadab688..049cc1c68 100644 --- a/src/lib/krb5/ccache/cc_file.c +++ b/src/lib/krb5/ccache/cc_file.c @@ -264,10 +264,6 @@ typedef struct _krb5_fcc_data { that can be changed. (Filename is fixed after initialization.) */ k5_mutex_t lock; - /* Grab this one before trying to get an advisory lock on the disk - file, since the facility is per-process, not per-thread. */ - k5_mutex_t disk_file_lock; - int file_is_locked; int file; krb5_flags flags; int mode; /* needed for locking code */ @@ -1172,9 +1168,7 @@ krb5_fcc_close_file (krb5_context context, krb5_fcc_data *data) return KRB5_FCC_INTERNAL; retval = krb5_unlock_file(context, data->file); - k5_mutex_unlock(&data->disk_file_lock); ret = close (data->file); - data->file_is_locked = 0; data->file = NO_FILE; if (retval) return retval; @@ -1212,11 +1206,7 @@ krb5_fcc_open_file (krb5_context context, krb5_ccache id, int mode) if (data->file != NO_FILE) { /* Don't know what state it's in; shut down and start anew. */ - if (data->file_is_locked) { - (void) krb5_unlock_file(context, data->file); - k5_mutex_unlock(&data->disk_file_lock); - data->file_is_locked = 0; - } + (void) krb5_unlock_file(context, data->file); (void) close (data->file); data->file = NO_FILE; } @@ -1245,17 +1235,10 @@ krb5_fcc_open_file (krb5_context context, krb5_ccache id, int mode) lock_flag = KRB5_LOCKMODE_SHARED; else lock_flag = KRB5_LOCKMODE_EXCLUSIVE; - retval = k5_mutex_lock(&data->disk_file_lock); - if (retval) { - close(f); - return retval; - } if ((retval = krb5_lock_file(context, f, lock_flag))) { - k5_mutex_unlock(&data->disk_file_lock); (void) close(f); return retval; } - data->file_is_locked = 1; if (mode == FCC_OPEN_AND_ERASE) { /* write the version number */ @@ -1378,8 +1361,6 @@ done: if (retval) { data->file = -1; (void) krb5_unlock_file(context, f); - (void) k5_mutex_unlock(&data->disk_file_lock); - data->file_is_locked = 0; (void) close(f); } return retval; @@ -1492,6 +1473,7 @@ static krb5_error_code dereference(krb5_context context, krb5_fcc_data *data) *fccsp = (*fccsp)->next; free(temp); k5_mutex_unlock(&krb5int_cc_file_mutex); + k5_mutex_assert_unlocked(&data->lock); free(data->filename); zap(data->buf, sizeof(data->buf)); if (data->file >= 0) { @@ -1499,9 +1481,7 @@ static krb5_error_code dereference(krb5_context context, krb5_fcc_data *data) krb5_fcc_close_file(context, data); k5_mutex_unlock(&data->lock); } - k5_mutex_assert_unlocked(&data->lock); k5_mutex_destroy(&data->lock); - k5_mutex_destroy(&data->disk_file_lock); free(data); } else k5_mutex_unlock(&krb5int_cc_file_mutex); @@ -1734,25 +1714,14 @@ krb5_fcc_resolve (krb5_context context, krb5_ccache *id, const char *residual) free(data); return kret; } - kret = k5_mutex_init(&data->disk_file_lock); - if (kret) { - k5_mutex_unlock(&krb5int_cc_file_mutex); - k5_mutex_unlock(&data->lock); - k5_mutex_destroy(&data->lock); - free(data->filename); - free(data); - return kret; - } /* data->version,mode filled in for real later */ data->version = data->mode = 0; - data->file_is_locked = 0; data->flags = KRB5_TC_OPENCLOSE; data->file = -1; data->valid_bytes = 0; setptr = malloc(sizeof(struct fcc_set)); if (setptr == NULL) { k5_mutex_unlock(&krb5int_cc_file_mutex); - k5_mutex_destroy(&data->disk_file_lock); k5_mutex_destroy(&data->lock); free(data->filename); free(data); @@ -2014,12 +1983,6 @@ krb5_fcc_generate_new (krb5_context context, krb5_ccache *id) retcode = k5_mutex_init(&data->lock); if (retcode) goto err_out; - retcode = k5_mutex_init(&data->disk_file_lock); - if (retcode) { - k5_mutex_destroy(&data->lock); - goto err_out; - } - data->file_is_locked = 0; /* Set up the filename */ strcpy(((krb5_fcc_data *) lid->data)->filename, scratch); @@ -2237,7 +2200,9 @@ krb5_fcc_set_flags(krb5_context context, krb5_ccache id, krb5_flags flags) /* XXX This should check for illegal combinations, if any.. */ if (flags & KRB5_TC_OPENCLOSE) { /* asking to turn on OPENCLOSE mode */ - if (!OPENCLOSE(id)) + if (!OPENCLOSE(id) + /* XXX Is this test necessary? */ + && ((krb5_fcc_data *) id->data)->file != NO_FILE) (void) krb5_fcc_close_file (context, ((krb5_fcc_data *) id->data)); } else { /* asking to turn off OPENCLOSE mode, meaning it must be