projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bug #58664
[pspp]
/
src
/
data
/
file-handle-def.c
diff --git
a/src/data/file-handle-def.c
b/src/data/file-handle-def.c
index 53e00be13a71b2c2f1ea8f3ee7621d0780180bba..716a029cc701a567d4c28c53ab0119fed66d003f 100644
(file)
--- a/
src/data/file-handle-def.c
+++ b/
src/data/file-handle-def.c
@@
-24,7
+24,6
@@
#include <string.h>
#include "data/dataset.h"
#include <string.h>
#include "data/dataset.h"
-#include "data/file-name.h"
#include "data/variable.h"
#include "libpspp/cast.h"
#include "libpspp/compiler.h"
#include "data/variable.h"
#include "libpspp/cast.h"
#include "libpspp/compiler.h"
@@
-116,12
+115,17
@@
fh_done (void)
HMAP_FOR_EACH_SAFE (handle, next,
struct file_handle, name_node, &named_handles)
unname_handle (handle);
HMAP_FOR_EACH_SAFE (handle, next,
struct file_handle, name_node, &named_handles)
unname_handle (handle);
+
+ free_handle (inline_file);
}
/* Free HANDLE and remove it from the global list. */
static void
free_handle (struct file_handle *handle)
{
}
/* Free HANDLE and remove it from the global list. */
static void
free_handle (struct file_handle *handle)
{
+ if (handle == NULL)
+ return;
+
/* Remove handle from global list. */
if (handle->id != NULL)
hmap_delete (&named_handles, &handle->name_node);
/* Remove handle from global list. */
if (handle->id != NULL)
hmap_delete (&named_handles, &handle->name_node);
@@
-154,6
+158,8
@@
unname_handle (struct file_handle *handle)
struct file_handle *
fh_ref (struct file_handle *handle)
{
struct file_handle *
fh_ref (struct file_handle *handle)
{
+ if (handle == fh_inline_file ())
+ return handle;
assert (handle->ref_cnt > 0);
handle->ref_cnt++;
return handle;
assert (handle->ref_cnt > 0);
handle->ref_cnt++;
return handle;
@@
-166,6
+172,8
@@
fh_unref (struct file_handle *handle)
{
if (handle != NULL)
{
{
if (handle != NULL)
{
+ if (handle == fh_inline_file ())
+ return;
assert (handle->ref_cnt > 0);
if (--handle->ref_cnt == 0)
free_handle (handle);
assert (handle->ref_cnt > 0);
if (--handle->ref_cnt == 0)
free_handle (handle);
@@
-410,7
+418,7
@@
fh_set_default_handle (struct file_handle *new_default_handle)
fh_unref (default_handle);
default_handle = new_default_handle;
if (default_handle != NULL)
fh_unref (default_handle);
default_handle = new_default_handle;
if (default_handle != NULL)
- fh_ref (default_handle);
+
default_handle =
fh_ref (default_handle);
}
\f
/* Information about a file handle's readers or writers. */
}
\f
/* Information about a file handle's readers or writers. */
@@
-495,14
+503,14
@@
fh_lock (struct file_handle *h, enum fh_referent mask UNUSED,
HMAP_FOR_EACH_WITH_HASH (lock, struct fh_lock, node, hash, &locks)
{
HMAP_FOR_EACH_WITH_HASH (lock, struct fh_lock, node, hash, &locks)
{
- if (
0 == compare_fh_locks (lock, key))
+ if (0 == compare_fh_locks (lock, key))
{
found_lock = true;
break;
}
}
{
found_lock = true;
break;
}
}
- if (
found_lock
)
+ if (
found_lock
)
{
if (strcmp (lock->type, type))
{
{
if (strcmp (lock->type, type))
{
@@
-523,7
+531,7
@@
fh_lock (struct file_handle *h, enum fh_referent mask UNUSED,
return NULL;
}
lock->open_cnt++;
return NULL;
}
lock->open_cnt++;
-
+
free_key (key);
free (key);
free_key (key);
free (key);
@@
-534,7
+542,7
@@
fh_lock (struct file_handle *h, enum fh_referent mask UNUSED,
found_lock = false;
HMAP_FOR_EACH_WITH_HASH (lock, struct fh_lock, node, hash, &locks)
{
found_lock = false;
HMAP_FOR_EACH_WITH_HASH (lock, struct fh_lock, node, hash, &locks)
{
- if (
0 == compare_fh_locks (lock, key))
+ if (0 == compare_fh_locks (lock, key))
{
found_lock = true;
break;
{
found_lock = true;
break;
@@
-609,7
+617,7
@@
fh_is_locked (const struct file_handle *handle, enum fh_access access)
HMAP_FOR_EACH_WITH_HASH (k, struct fh_lock, node, hash, &locks)
{
HMAP_FOR_EACH_WITH_HASH (k, struct fh_lock, node, hash, &locks)
{
- if (
0 == compare_fh_locks (k, &key))
+ if (0 == compare_fh_locks (k, &key))
{
is_locked = true;
break;
{
is_locked = true;
break;
@@
-710,7
+718,7
@@
fh_get_identity (const struct file_handle *fh)
struct file_identity *identity = xmalloc (sizeof *identity);
const char *file_name = fh_get_file_name (fh);
struct file_identity *identity = xmalloc (sizeof *identity);
const char *file_name = fh_get_file_name (fh);
-
+
#if !(defined _WIN32 || defined __WIN32__)
struct stat s;
if (lstat (file_name, &s) == 0)
#if !(defined _WIN32 || defined __WIN32__)
struct stat s;
if (lstat (file_name, &s) == 0)
@@
-762,7
+770,7
@@
fh_get_identity (const struct file_handle *fh)
size_t bufsize;
size_t pathlen = 255;
char *cname = NULL;
size_t bufsize;
size_t pathlen = 255;
char *cname = NULL;
- do
+ do
{
bufsize = pathlen;
cname = xrealloc (cname, bufsize);
{
bufsize = pathlen;
cname = xrealloc (cname, bufsize);