typedef struct exfile_entry_t {
int fd; //!< File descriptor associated with an entry.
- int dup;
uint32_t hash; //!< Hash for cheap comparison.
time_t last_used; //!< Last time the entry was used.
char *filename; //!< Filename.
entry->hash = 0;
entry->fd = -1;
- entry->dup = -1;
/*
* Issue close trigger *after* we've closed the fd
ef->entries[i].hash = hash;
ef->entries[i].filename = talloc_strdup(ef->entries, filename);
ef->entries[i].fd = -1;
- ef->entries[i].dup = -1;
ef->entries[i].fd = open(filename, O_RDWR | O_APPEND | O_CREAT, permissions);
if (ef->entries[i].fd < 0) {
* Return holding the mutex for the entry.
*/
ef->entries[i].last_used = now;
- ef->entries[i].dup = dup(ef->entries[i].fd);
- if (ef->entries[i].dup < 0) {
- fr_strerror_printf("Failed calling dup(): %s", strerror(errno));
- goto error;
- }
exfile_trigger_exec(ef, request, &ef->entries[i], "reserve");
- rad_assert(ef->entries[i].dup >= 0); /* try to shut up Coverity */
-
/* coverity[missing_unlock] */
- return ef->entries[i].dup;
+ return ef->entries[i].fd;
}
/** Close the log file. Really just return it to the pool.
/*
* Unlock the bytes that we had previously locked.
*/
- if (ef->entries[i].dup == fd) {
- if (ef->locking) (void) rad_unlockfd(ef->entries[i].dup, 0);
- close(ef->entries[i].dup); /* releases the fcntl lock */
- ef->entries[i].dup = -1;
+ if (ef->entries[i].fd == fd) {
+ if (ef->locking) (void) rad_unlockfd(ef->entries[i].fd, 0);
pthread_mutex_unlock(&(ef->mutex));