summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2006-10-15 08:57:52 +0000
committerAkira TAGOH <akira@tagoh.org>2006-10-15 08:57:52 +0000
commit5985b791d04f2ae7e699f719d29c7594540bb2dd (patch)
treefd378db6ca913465cbb8c55fb5cb0a68c893c31f
parent5d23d26777b411f70c77c5bb1cf61abbdd6a50ff (diff)
* hieroglyph/hgfile.c (hg_file_io_synchronous): new function.
(hg_file_object_write): call fsync after writing according to the current state of I/O synchronous.
-rw-r--r--ChangeLog4
-rw-r--r--hieroglyph/hgfile.c9
-rw-r--r--hieroglyph/hgfile.h1
-rw-r--r--hieroglyph/version.h.in2
4 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 2299bc2..ef8c80d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2006-10-15 Akira TAGOH <at@gclab.org>
+ * hieroglyph/hgfile.c (hg_file_io_synchronous): new function.
+ (hg_file_object_write): call fsync after writing according to
+ the current state of I/O synchronous.
+
* hieroglyph/hgstring.c (hg_string_append_printf): new function.
(hg_string_append_vprintf): new function.
diff --git a/hieroglyph/hgfile.c b/hieroglyph/hgfile.c
index 56afc46..458578a 100644
--- a/hieroglyph/hgfile.c
+++ b/hieroglyph/hgfile.c
@@ -79,6 +79,7 @@ HgFileObject *__hg_file_stdin = NULL;
HgFileObject *__hg_file_stdout = NULL;
HgFileObject *__hg_file_stderr = NULL;
static gboolean __hg_file_is_initialized = FALSE;
+static gboolean __hg_file_is_io_synchronous = FALSE;
static HgMemPool *__hg_file_mem_pool = NULL;
static HgAllocator *__hg_file_allocator = NULL;
static HgObjectVTable __hg_file_vtable = {
@@ -259,6 +260,12 @@ hg_file_is_initialized(void)
return __hg_file_is_initialized;
}
+void
+hg_file_io_synchronous(gboolean flag)
+{
+ __hg_file_is_io_synchronous = flag;
+}
+
/* file object */
HgFileObject *
hg_file_object_new(HgMemPool *pool,
@@ -622,6 +629,8 @@ hg_file_object_write(HgFileObject *object,
errno = 0;
retval = write(object->is.file.fd, buffer, size * n);
object->error = errno;
+ if (__hg_file_is_io_synchronous)
+ fsync(object->is.file.fd);
break;
case HG_FILE_TYPE_BUFFER:
if ((object->is.buf.bufsize - object->is.buf.pos) < (size * n))
diff --git a/hieroglyph/hgfile.h b/hieroglyph/hgfile.h
index 0b78df7..384556f 100644
--- a/hieroglyph/hgfile.h
+++ b/hieroglyph/hgfile.h
@@ -40,6 +40,7 @@ extern HgFileObject *__hg_file_stderr;
void hg_file_init (void);
void hg_file_finalize (void);
gboolean hg_file_is_initialized(void);
+void hg_file_io_synchronous(gboolean flag);
/* file object */
HgFileObject *hg_file_object_new (HgMemPool *pool,
diff --git a/hieroglyph/version.h.in b/hieroglyph/version.h.in
index b64af69..523a81b 100644
--- a/hieroglyph/version.h.in
+++ b/hieroglyph/version.h.in
@@ -29,7 +29,7 @@
G_BEGIN_DECLS
#define HIEROGLYPH_VERSION "@VERSION@"
-#define HIEROGLYPH_UUID "89062011-2c6e-4e6c-9af6-85e816e04551"
+#define HIEROGLYPH_UUID "377e7dd8-f13c-4bf9-9d0f-cbb07441ef3e"
const char *__hg_rcsid G_GNUC_UNUSED = "$Rev$";