Commit 7410706b authored by Jeffrey Stedfast's avatar Jeffrey Stedfast Committed by Jeffrey Stedfast
Browse files

Fixes bug #108574

2003-03-16  Jeffrey Stedfast  <fejj@ximian.com>

	Fixes bug #108574

	* backends/xml-dir.c (gconf_xml_doc_dump): Replacement for
	xmlDocDump() which is not reliable. While we're at it, also dump
	formatted xml.
	(dir_sync): Call the new gconf_xml_doc_dump() rather than
	xmlDocDump() because we don't want to risk losing user settings.
parent c490f6bb
2003-03-16 Jeffrey Stedfast <fejj@ximian.com>
Fixes bug #108574
* backends/xml-dir.c (gconf_xml_doc_dump): Replacement for
xmlDocDump() which is not reliable. While we're at it, also dump
formatted xml.
(dir_sync): Call the new gconf_xml_doc_dump() rather than
xmlDocDump() because we don't want to risk losing user settings.
2003-07-17 Havoc Pennington <hp@redhat.com>
* gconf/gconf-value.h: flags can't be 0, patch from
......
......@@ -345,6 +345,50 @@ dir_useless (Dir *d)
g_hash_table_size (d->entry_cache) == 0;
}
/* for info on why this is used rather than xmlDocDump or xmlSaveFile
* and friends, see http://bugzilla.gnome.org/show_bug.cgi?id=108329 */
static int
gconf_xml_doc_dump (FILE *fp, xmlDocPtr doc)
{
char *xmlbuf;
int fd, n;
xmlDocDumpFormatMemory (doc, (xmlChar **) &xmlbuf, &n, TRUE);
if (n <= 0)
{
errno = ENOMEM;
return -1;
}
if (fwrite (xmlbuf, sizeof (xmlChar), n, fp) < n)
{
xmlFree (xmlbuf);
return -1;
}
xmlFree (xmlbuf);
/* From the fflush(3) man page:
*
* Note that fflush() only flushes the user space buffers provided by the
* C library. To ensure that the data is physically stored on disk the
* kernel buffers must be flushed too, e.g. with sync(2) or fsync(2).
*/
/* flush user-space buffers */
if (fflush (fp) != 0)
return -1;
if ((fd = fileno (fp)) == -1)
return -1;
/* sync kernel-space buffers to disk */
if (fsync (fd) == -1)
return -1;
return 0;
}
gboolean
dir_sync (Dir *d,
gboolean *deleted,
......@@ -444,7 +488,7 @@ dir_sync (Dir *d,
goto failed_end_of_sync;
}
if (xmlDocDump (outfile, d->doc) < 0)
if (gconf_xml_doc_dump (outfile, d->doc) < 0)
{
gconf_set_error (err, GCONF_ERROR_FAILED,
_("Failed to write XML data to `%s': %s"),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment