Free the location path as we walk down it. (create_backends_list):
2001-06-19 Bradford Hovinen <hovinen@ximian.com> * archive.c (archive_set_current_location): Free the location path as we walk down it. (create_backends_list): Implement (merge_backend_lists): Implement (archive_set_current_location): Call above functions (create_backends_list): Get rid of dummy first element (archive_set_current_location): Don't use backends->next when calling rollback_backends_to * location.c (run_backend_proc): Remember to close the writing end (location_store): Change g_error to g_critical (run_backend_proc): Don't getenv PATH (run_backend_proc): Make sure to close other end of pipe in child process 2001-06-18 Bradford Hovinen <hovinen@ximian.com> * location.c (location_store): Use GString API * config-log.c (slave_data_cb): Don't use == to test IO conditions
This commit is contained in:
parent
aa7315ed93
commit
172e5c0939
5 changed files with 139 additions and 48 deletions
|
@ -1,5 +1,24 @@
|
|||
2001-06-19 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* archive.c (archive_set_current_location): Free the location path
|
||||
as we walk down it.
|
||||
(create_backends_list): Implement
|
||||
(merge_backend_lists): Implement
|
||||
(archive_set_current_location): Call above functions
|
||||
(create_backends_list): Get rid of dummy first element
|
||||
(archive_set_current_location): Don't use backends->next when
|
||||
calling rollback_backends_to
|
||||
|
||||
* location.c (run_backend_proc): Remember to close the writing end
|
||||
(location_store): Change g_error to g_critical
|
||||
(run_backend_proc): Don't getenv PATH
|
||||
(run_backend_proc): Make sure to close other end of pipe in child
|
||||
process
|
||||
|
||||
2001-06-18 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
||||
* location.c (location_store): Use GString API
|
||||
|
||||
* config-log.c (slave_data_cb): Don't use == to test IO conditions
|
||||
|
||||
2001-06-01 Bradford Hovinen <hovinen@ximian.com>
|
||||
|
|
|
@ -426,6 +426,92 @@ add_location_cb (Location *location, gchar *backend_id, GList *backends)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Create a list of backends that differ between location1 and the common
|
||||
* parent of location1 and location2 */
|
||||
|
||||
static GList *
|
||||
create_backends_list (Location *location1, Location *location2)
|
||||
{
|
||||
GList *location_path, *backends, *tmp;
|
||||
|
||||
location_path = location_find_path_from_common_parent
|
||||
(location1, location2);
|
||||
|
||||
/* Skip the first entry -- it is the common parent */
|
||||
tmp = location_path;
|
||||
location_path = location_path->next;
|
||||
g_list_free_1 (tmp);
|
||||
|
||||
backends = g_list_append (NULL, NULL);
|
||||
|
||||
while (location_path != NULL) {
|
||||
if (location_path->data != NULL) {
|
||||
location_foreach_backend
|
||||
(LOCATION (location_path->data),
|
||||
(LocationBackendCB) add_location_cb,
|
||||
backends);
|
||||
}
|
||||
|
||||
tmp = location_path;
|
||||
location_path = location_path->next;
|
||||
g_list_free_1 (tmp);
|
||||
}
|
||||
|
||||
tmp = backends;
|
||||
backends = backends->next;
|
||||
g_list_free_1 (tmp);
|
||||
|
||||
return backends;
|
||||
}
|
||||
|
||||
/* Merge two backend lists, eliminating duplicates */
|
||||
|
||||
GList *
|
||||
merge_backend_lists (GList *backends1, GList *backends2)
|
||||
{
|
||||
GList *head = NULL, *tail = NULL, *tmp;
|
||||
int res;
|
||||
|
||||
backends1 = g_list_sort (backends1, (GCompareFunc) strcmp);
|
||||
backends2 = g_list_sort (backends2, (GCompareFunc) strcmp);
|
||||
|
||||
while (backends1 && backends2) {
|
||||
res = strcmp (backends1->data, backends2->data);
|
||||
|
||||
if (res < 0) {
|
||||
if (tail != NULL) tail->next = backends1;
|
||||
else head = backends1;
|
||||
tail = backends1;
|
||||
backends1 = backends1->next;
|
||||
}
|
||||
else if (res > 0) {
|
||||
if (tail != NULL) tail->next = backends2;
|
||||
else head = backends2;
|
||||
tail = backends2;
|
||||
backends2 = backends2->next;
|
||||
} else {
|
||||
if (tail != NULL) tail->next = backends1;
|
||||
else head = backends1;
|
||||
tail = backends1;
|
||||
backends1 = backends1->next;
|
||||
tmp = backends2;
|
||||
backends2 = backends2->next;
|
||||
g_list_free_1 (tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (backends1 != NULL) {
|
||||
if (tail != NULL) tail->next = backends1;
|
||||
else head = backends1;
|
||||
}
|
||||
else {
|
||||
if (tail != NULL) tail->next = backends2;
|
||||
else head = backends2;
|
||||
}
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
/**
|
||||
* archive_set_current_location:
|
||||
* @archive: object
|
||||
|
@ -438,7 +524,7 @@ add_location_cb (Location *location, gchar *backend_id, GList *backends)
|
|||
void
|
||||
archive_set_current_location (Archive *archive, Location *location)
|
||||
{
|
||||
GList *location_path, *backends;
|
||||
GList *backends1, *backends2, *backends, *tmp;
|
||||
Location *old_location = archive_get_current_location (archive);
|
||||
|
||||
g_return_if_fail (archive != NULL);
|
||||
|
@ -448,23 +534,11 @@ archive_set_current_location (Archive *archive, Location *location)
|
|||
|
||||
archive_set_current_location_id (archive, location_get_id (location));
|
||||
|
||||
location_path = location_find_path_from_common_parent
|
||||
(location, old_location);
|
||||
backends1 = create_backends_list (location, old_location);
|
||||
backends2 = create_backends_list (old_location, location);
|
||||
backends = merge_backend_lists (backends1, backends2);
|
||||
|
||||
backends = g_list_append (NULL, NULL);
|
||||
|
||||
while (location_path != NULL) {
|
||||
if (location_path->data != NULL) {
|
||||
location_foreach_backend
|
||||
(LOCATION (location_path->data),
|
||||
(LocationBackendCB) add_location_cb,
|
||||
backends);
|
||||
}
|
||||
|
||||
location_path = location_path->next;
|
||||
}
|
||||
|
||||
location_rollback_backends_to (location, NULL, backends->next, TRUE);
|
||||
location_rollback_backends_to (location, NULL, backends, TRUE);
|
||||
|
||||
g_list_free (backends);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
<contains backend="boot-conf"/>
|
||||
<contains backend="disks-conf"/>
|
||||
<contains backend="memory-conf"/>
|
||||
<contains backend="mouse-conf"/>
|
||||
<contains backend="nameresolution-conf"/>
|
||||
<contains backend="network-conf"/>
|
||||
<contains backend="print-conf"/>
|
||||
<contains backend="shares-conf"/>
|
||||
|
|
|
@ -505,34 +505,33 @@ location_store (Location *location, gchar *backend_id, FILE *input,
|
|||
StoreType store_type)
|
||||
{
|
||||
xmlDocPtr doc;
|
||||
char *buffer = NULL;
|
||||
int len = 0, bytes_read = 0;
|
||||
char buffer[2048];
|
||||
int t = 0;
|
||||
GString *doc_str;
|
||||
|
||||
g_return_if_fail (location != NULL);
|
||||
g_return_if_fail (IS_LOCATION (location));
|
||||
|
||||
fflush (input);
|
||||
|
||||
do {
|
||||
DEBUG_MSG ("Iteration");
|
||||
if (!len) buffer = g_new (char, 4097);
|
||||
else buffer = g_renew (char, buffer, len + 4097);
|
||||
bytes_read = read (fileno (input), buffer + len, 4096);
|
||||
buffer[len + bytes_read] = '\0';
|
||||
len += 4096;
|
||||
} while (bytes_read == 4096);
|
||||
fcntl (fileno (input), F_SETFL, 0);
|
||||
|
||||
if (len >= 4096 && len > 0) {
|
||||
DEBUG_MSG ("Data found; parsing");
|
||||
doc = xmlParseMemory (buffer, len - 4096 + bytes_read);
|
||||
g_free (buffer);
|
||||
doc_str = g_string_new ("");
|
||||
|
||||
while ((t = read (fileno (input), buffer, sizeof (buffer) - 1)) != 0) {
|
||||
buffer[t] = '\0';
|
||||
g_string_append (doc_str, buffer);
|
||||
}
|
||||
|
||||
if (doc_str->len > 0) {
|
||||
doc = xmlParseDoc (doc_str->str);
|
||||
location_store_xml (location, backend_id, doc, store_type);
|
||||
|
||||
xmlFreeDoc (doc);
|
||||
} else {
|
||||
g_error ("No data to store");
|
||||
g_critical ("No data to store");
|
||||
}
|
||||
|
||||
g_string_free (doc_str, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1486,31 +1485,32 @@ run_backend_proc (gchar *backend_id, gboolean do_get)
|
|||
gchar *path, *path1;
|
||||
|
||||
dup2 (fd[c_fd], c_fd);
|
||||
close (fd[p_fd]);
|
||||
for (i = 3; i < FOPEN_MAX; i++) close (i);
|
||||
|
||||
path = g_getenv ("PATH");
|
||||
if (strstr (backend_id, "-conf"))
|
||||
args[0] = g_concat_dir_and_file (XST_BACKEND_LOCATION,
|
||||
backend_id);
|
||||
else
|
||||
args[0] = gnome_is_program_in_path (backend_id);
|
||||
|
||||
if (!strstr (path, XST_BACKEND_LOCATION)) {
|
||||
path1 = g_strconcat ("PATH=", XST_BACKEND_LOCATION,
|
||||
":", path, NULL);
|
||||
putenv (path1);
|
||||
}
|
||||
|
||||
args[0] = gnome_is_program_in_path (backend_id);
|
||||
args[1] = do_get ? "--get" : "--set";
|
||||
args[2] = NULL;
|
||||
|
||||
if (!args[0]) {
|
||||
if (args[0] == NULL) {
|
||||
g_warning ("Backend not in path: %s", backend_id);
|
||||
close (c_fd);
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
execv (args[0], args);
|
||||
exit (-1);
|
||||
|
||||
execv (args[0], args);
|
||||
|
||||
g_warning ("Could not launch backend %s: %s",
|
||||
args[0], g_strerror (errno));
|
||||
exit (-1);
|
||||
return 0;
|
||||
} else {
|
||||
close (fd[c_fd]);
|
||||
return fd[p_fd];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <glib.h>
|
||||
|
||||
/* Uncomment this if you want debugs: */
|
||||
/* #define DEBUG_ME_MORE */
|
||||
#define DEBUG_ME_MORE
|
||||
|
||||
#ifdef DEBUG_ME_MORE
|
||||
# ifdef __GNUC__
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue