aboutsummaryrefslogtreecommitdiffstats
path: root/libibex
diff options
context:
space:
mode:
authorNot Zed <NotZed@HelixCode.com>2000-12-24 08:58:02 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-12-24 08:58:02 +0800
commit5674966eeb7eecfa109ad419f1c997dba69ff0af (patch)
treea439ac65139c39f3f551573b1c9f14a8e56b1c82 /libibex
parentd5b5b5f0979f0819561fbec36a417a6dcfc3d4d5 (diff)
downloadgsoc2013-evolution-5674966eeb7eecfa109ad419f1c997dba69ff0af.tar.gz
gsoc2013-evolution-5674966eeb7eecfa109ad419f1c997dba69ff0af.tar.zst
gsoc2013-evolution-5674966eeb7eecfa109ad419f1c997dba69ff0af.zip
Merge from camel-mt-branch.
2000-12-24 Not Zed <NotZed@HelixCode.com> * Merge from camel-mt-branch. svn path=/trunk/; revision=7152
Diffstat (limited to 'libibex')
-rw-r--r--libibex/ChangeLog24
-rw-r--r--libibex/Makefile.am5
-rw-r--r--libibex/dumpindex.c4
-rw-r--r--libibex/ibex_block.c38
-rw-r--r--libibex/ibex_internal.h19
-rw-r--r--libibex/testindex.c44
6 files changed, 128 insertions, 6 deletions
diff --git a/libibex/ChangeLog b/libibex/ChangeLog
index 877d9b8e29..2d3fe7bace 100644
--- a/libibex/ChangeLog
+++ b/libibex/ChangeLog
@@ -1,3 +1,27 @@
+2000-12-24 Not Zed <NotZed@HelixCode.com>
+
+ * Merge from camel-mt-branch.
+
+2000-12-18 Not Zed <NotZed@HelixCode.com>
+
+ * dumpindex.c (main): Same here.
+
+ * testindex.c (main): Add a g_thread_init(). Sigh, glib's thread
+ stuff is snot.
+ (read_words): Setup another flat-out thread to test
+ multithreadedness at little bit.
+
+ * ibex_block.c (ibex_index_buffer): Add locking around internal
+ calls.
+ (ibex_open): Init the locking mutex.
+ (ibex_close): Free the locking mutex.
+ (ibex_unindex):
+ (ibex_find):
+ (ibex_find_name):
+ (ibex_contains_name): Add locking around internal calls.
+
+ * ibex_internal.h (struct ibex): Add a lock. Include config.h
+
2000-12-13 Christopher James Lahey <clahey@helixcode.com>
* disktail.c (tail_compress):
diff --git a/libibex/Makefile.am b/libibex/Makefile.am
index 61f3d72004..ab7c92206c 100644
--- a/libibex/Makefile.am
+++ b/libibex/Makefile.am
@@ -18,16 +18,17 @@ noinst_HEADERS = \
index.h
INCLUDES = -I$(srcdir) $(GLIB_CFLAGS) $(UNICODE_CFLAGS) \
+ $(THREADS_CFLAGS) \
-DG_LOG_DOMAIN=\"libibex\"
noinst_PROGRAMS = dumpindex testindex
dumpindex_SOURCES = dumpindex.c
-dumpindex_LDADD = libibex.la $(GLIB_LIBS) $(UNICODE_LIBS)
+dumpindex_LDADD = libibex.la $(GLIB_LIBS) $(UNICODE_LIBS) $(THREADS_LIBS)
testindex_SOURCES = testindex.c
-testindex_LDADD = libibex.la $(GLIB_LIBS) $(UNICODE_LIBS) -lm
+testindex_LDADD = libibex.la $(GLIB_LIBS) $(UNICODE_LIBS) $(THREADS_LIBS) -lm
#noinst_PROGRAMS = mkindex lookup
#
diff --git a/libibex/dumpindex.c b/libibex/dumpindex.c
index cf4f02cc8a..410a7083d6 100644
--- a/libibex/dumpindex.c
+++ b/libibex/dumpindex.c
@@ -37,6 +37,10 @@ int main(int argc, char **argv)
{
ibex *ib;
+#ifdef ENABLE_THREADS
+ g_thread_init(0);
+#endif
+
if (argc != 2) {
printf("Usage: %s ibexfile\n", argv[0]);
return 1;
diff --git a/libibex/ibex_block.c b/libibex/ibex_block.c
index 41388162c4..faeee232ac 100644
--- a/libibex/ibex_block.c
+++ b/libibex/ibex_block.c
@@ -215,12 +215,17 @@ ibex_index_buffer (ibex *ib, char *name, char *buffer, size_t len, size_t *unrea
p = q;
}
done:
+ IBEX_LOCK(ib);
+
d(printf("name %s count %d size %d\n", name, wordlist->len, len));
if (!ib->predone) {
ib->words->klass->index_pre(ib->words);
ib->predone = TRUE;
}
ib->words->klass->add_list(ib->words, name, wordlist);
+
+ IBEX_UNLOCK(ib);
+
ret = 0;
error:
for (i=0;i<wordlist->len;i++)
@@ -246,12 +251,18 @@ ibex *ibex_open (char *file, int flags, int mode)
/* FIXME: the blockcache or the wordindex needs to manage the other one */
ib->words = ib->blocks->words;
+#ifdef ENABLE_THREADS
+ ib->lock = g_mutex_new();
+#endif
return ib;
}
int ibex_save (ibex *ib)
{
d(printf("syncing database\n"));
+
+ IBEX_LOCK(ib);
+
if (ib->predone) {
ib->words->klass->index_post(ib->words);
ib->predone = FALSE;
@@ -259,6 +270,9 @@ int ibex_save (ibex *ib)
ib->words->klass->sync(ib->words);
/* FIXME: some return */
ibex_block_cache_sync(ib->blocks);
+
+ IBEX_UNLOCK(ib);
+
return 0;
}
@@ -275,6 +289,9 @@ int ibex_close (ibex *ib)
ib->words->klass->close(ib->words);
ibex_block_cache_close(ib->blocks);
+#ifdef ENABLE_THREADS
+ g_mutex_free(ib->lock);
+#endif
g_free(ib);
return ret;
}
@@ -282,32 +299,47 @@ int ibex_close (ibex *ib)
void ibex_unindex (ibex *ib, char *name)
{
d(printf("trying to unindex '%s'\n", name));
+ IBEX_LOCK(ib);
ib->words->klass->unindex_name(ib->words, name);
+ IBEX_UNLOCK(ib);
}
GPtrArray *ibex_find (ibex *ib, char *word)
{
char *normal;
int len;
+ GPtrArray *ret;
len = strlen(word);
normal = alloca(len+1);
ibex_normalise_word(word, word+len, normal);
- return ib->words->klass->find(ib->words, normal);
+ IBEX_LOCK(ib);
+ ret = ib->words->klass->find(ib->words, normal);
+ IBEX_UNLOCK(ib);
+ return ret;
}
gboolean ibex_find_name (ibex *ib, char *name, char *word)
{
char *normal;
int len;
+ gboolean ret;
len = strlen(word);
normal = alloca(len+1);
ibex_normalise_word(word, word+len, normal);
- return ib->words->klass->find_name(ib->words, name, normal);
+ IBEX_LOCK(ib);
+ ret = ib->words->klass->find_name(ib->words, name, normal);
+ IBEX_UNLOCK(ib);
+ return ret;
}
gboolean ibex_contains_name(ibex *ib, char *name)
{
- return ib->words->klass->contains_name(ib->words, name);
+ gboolean ret;
+
+ IBEX_LOCK(ib);
+ ret = ib->words->klass->contains_name(ib->words, name);
+ IBEX_UNLOCK(ib);
+ return ret;
}
diff --git a/libibex/ibex_internal.h b/libibex/ibex_internal.h
index 0eb4b625ce..f2212799c6 100644
--- a/libibex/ibex_internal.h
+++ b/libibex/ibex_internal.h
@@ -18,6 +18,8 @@
* Boston, MA 02111-1307, USA.
*/
+#include "config.h"
+
#include <glib.h>
#include "ibex.h"
@@ -29,4 +31,21 @@ struct ibex {
struct _memcache *blocks;
struct _IBEXWord *words;
int predone;
+
+ /* sigh i hate glib's mutex stuff too */
+#ifdef ENABLE_THREADS
+ GMutex *lock;
+#endif
+
};
+
+#ifdef ENABLE_THREADS
+/*#define IBEX_LOCK(ib) (printf(__FILE__ "%d: %s: locking ibex\n", __LINE__, __FUNCTION__), g_mutex_lock(ib->lock))
+ #define IBEX_UNLOCK(ib) (printf(__FILE__ "%d: %s: unlocking ibex\n", __LINE__, __FUNCTION__), g_mutex_unlock(ib->lock))*/
+#define IBEX_LOCK(ib) (g_mutex_lock(ib->lock))
+#define IBEX_UNLOCK(ib) (g_mutex_unlock(ib->lock))
+#else
+#define IBEX_LOCK(ib)
+#define IBEX_UNLOCK(ib)
+#endif
+
diff --git a/libibex/testindex.c b/libibex/testindex.c
index e21d73ff06..a3b6a9ce03 100644
--- a/libibex/testindex.c
+++ b/libibex/testindex.c
@@ -6,6 +6,10 @@
#include <string.h>
#include "ibex_internal.h"
+#ifdef ENABLE_THREADS
+#include <pthread.h>
+#endif
+
void word_index_mem_dump_info(struct _IBEXWord *idx);
/*
@@ -69,6 +73,29 @@ static char *getword(GPtrArray *words, float m, float s)
return words->pdata[index];
}
+#ifdef ENABLE_THREADS
+int do_read_words;
+
+static void *
+read_words(void *in)
+{
+ ibex *ib = in;
+ GPtrArray *a;
+ int lastlen = 0;
+ int i;
+
+ while (do_read_words) {
+ a = ibex_find(ib, "joneses");
+ if (a->len != lastlen) {
+ printf("Found %d joneses!\n", a->len);
+ lastlen = a->len;
+ }
+ for (i=0;i<a->len;i++)
+ g_free(a->pdata[i]);
+ g_ptr_array_free(a, TRUE);
+ }
+}
+#endif
int main(int argc, char **argv)
{
@@ -83,9 +110,15 @@ int main(int argc, char **argv)
int files;
char *dict;
+#ifdef ENABLE_THREADS
+ pthread_t id;
+
+ g_thread_init(0);
+#endif
+
srand(0xABADF00D);
- files = 80000;
+ files = 8000;
dict = "/usr/dict/words";
/* read words into an array */
@@ -119,6 +152,10 @@ int main(int argc, char **argv)
return 1;
}
+#ifdef ENABLE_THREADS
+ do_read_words = 1;
+ pthread_create(&id, 0, read_words, ib);
+#endif
printf("Adding %d files\n", files);
/* simulate adding new words to a bunch of files */
@@ -151,6 +188,11 @@ int main(int argc, char **argv)
word_index_mem_dump_info(ib->words);
+#ifdef ENABLE_THREADS
+ do_read_words = 0;
+ pthread_join(id, 0);
+#endif
+
ibex_close(ib);
return 0;
ef='/~lantw44/cgit/gsoc2013-evolution/commit/?h=Release09pre3&id=437a211d4fa2adf653a6f5bc7a0062d142b7e8ab'>Updated Slovenian translationAndraz Tori2001-01-231-260/+313 * new splash. /tigTuomas Kuosmanen2001-01-232-0/+5 * Change "Path:" label to "Namespace:" for IMAP. Use $MAILDIR rather thanDan Winship2001-01-232-2/+20 * Updated Slovenian translationAndraz Tori2001-01-231-45/+45 * Function to add a store/storage mapping. (add_storage): Use it.Dan Winship2001-01-234-4/+32 * s/filter-driver.h/camel-filter-driver.h/ and update first arg ofDan Winship2001-01-231-0/+20 * Updated Slovenian translationAndraz Tori2001-01-231-3288/+4567 * Update for filter code movesDan Winship2001-01-232-2/+5 * s/filter-driver.h/camel-filter-driver.h/ and update first arg ofDan Winship2001-01-237-14/+14 * Fixed gal_define_views_dialog_new to be called with its proper argument.Jon Trowbridge2001-01-232-1/+6 * Added temp profiling files.Not Zed2001-01-222-1/+7 * Added profiling temp files.Not Zed2001-01-2215-2/+55 * Removed the temporary get mail button.Not Zed2001-01-222-6/+4 * Removed, now lives in camel-filter-search.*Not Zed2001-01-226-1712/+10 * remove a warning with conditional news compilation.Not Zed2001-01-2211-1497/+593 * Updated sl translationsAndraz Tori2001-01-222-0/+4 * When removing phantom nodes, check for the end node too.Not Zed2001-01-224-18/+26 * Initialize collection field to NULL. Set the collection on the model asChristopher James Lahey2001-01-2210-82/+343 * disable cmdline subdir here tooDave Camp2001-01-221-1/+0 * Helps if I spell stuff correctly so it can pass the tests ;-)Jeffrey Stedfast2001-01-223-4/+10 * Updates evolution/po/da.po gal/po/da.po galeon/po/da.po gconf/po/da.poKenneth Christiansen2001-01-221-816/+948 * Remove cmdline for nowMiguel de Icaza2001-01-221-1/+0 * Initialize OpenPGP.Jeffrey Stedfast2001-01-224-20/+25 * Fix MakefileMiguel de Icaza2001-01-221-3/+2 * Make the output a little prettier. Okay, so I'm anal...Jeffrey Stedfast2001-01-223-17/+10 * Made the cursor move when rows are inserted or deleted. If in single modeChristopher James Lahey2001-01-221-0/+11 * Add cmdline to the buildMiguel de Icaza2001-01-221-1/+2 * Remove the X-Evolution header before we send.Jeffrey Stedfast2001-01-222-3/+9 * Fixed some memory leaks dealing with content-type temp strings. AlsoJeffrey Stedfast2001-01-222-17/+91 * Don't forget to unref the filters. (pgp_mime_part_verify): Same.Jeffrey Stedfast2001-01-222-27/+32 * (Fix #1222: doing File->New->Mail Message doesn't include .sig)Jason Leach2001-01-222-1/+23 * Updated Slovenian translationAndraz Tori2001-01-221-4390/+3733 * Fix bug #1250; now we present a confirmation dialog before deleting theFederico Mena Quintero2001-01-222-7/+16 * Updated Japanese translation.Akira Tagoh2001-01-211-323/+2697 * Updated header comment and fixed some ref/unref count problems in theJeffrey Stedfast2001-01-212-6/+12 * The Doc directory was removed because it does not build, and Dave Camp cant s...Miguel de Icaza2001-01-211-2/+2 * Updated header comment and fixed some ref/unref count problems in theJeffrey Stedfast2001-01-212-25/+33 * Add composer bitsMiguel de Icaza2001-01-211-0/+10 * Ok, conflicting configure.in confused meMiguel de Icaza2001-01-211-6/+0 * Update to reflect changes to configure.inMiguel de Icaza2001-01-211-0/+6 * Use the new gal_view_set_title function.Christopher James Lahey2001-01-217-56/+311 * Added function e_xml_get_bool_prop_by_name_with_default.Christopher James Lahey2001-01-212-0/+23 * Added draw-focus="true" and selection-mode="browse" attributes to theChristopher James Lahey2001-01-212-4/+9 * Made this conform to the new prototype for e_popup_menu_run.Christopher James Lahey2001-01-218-105/+341 * Init a cancel field in the message. (mail_msg_free): Free it.Not Zed2001-01-216-113/+722 * Added an exception to CamelFilterGetFolderFunc.Not Zed2001-01-213-19/+48 * Strip leading space from the transport url gotten from the message.Jeffrey Stedfast2001-01-212-2/+10 * ettore likes this betterJakub Steiner2001-01-211-0/+0 * Fix bug #1243. Turn on the Y expand/fill options for the date widgets inFederico Mena Quintero2001-01-213-29/+37 * Fix memory leak: Unref some stuff if we're not showing the tooltip.Iain Holmes2001-01-211-1/+2 * Doc updates - FedericoFederico Mena Quintero2001-01-206-456/+456 * Unset the GTK_CAN_FOCUS flag on the ECalendar. (e_calendar_focus_in):Federico Mena Quintero2001-01-202-33/+14 * Unset the GTK_CAN_FOCUS flag on the weekday picker. This will do until itFederico Mena Quintero2001-01-202-0/+8 * If the name is empty string, use the address.Jeffrey Stedfast2001-01-202-1/+7 * Update for e_popup_menu_run change.Dan Winship2001-01-203-2/+13 * Update for e_popup_menu_run prototype change.Dan Winship2001-01-203-2/+8 * s/GdkEventButton/GdkEvent/Dan Winship2001-01-204-5/+8 * updateKenneth Christiansen2001-01-201-1979/+2716 * New function to add a folder and any parents of it that don't yet exist.Dan Winship2001-01-202-6/+34 * (subscribe_folder): add a missing UNLOCKDan Winship2001-01-202-0/+2 * Set the delete bit *before* copying to the default folder.Jeffrey Stedfast2001-01-202-4/+9 * evo .9 splashJakub Steiner2001-01-201-0/+0 * New function. Obvious.Dan Winship2001-01-203-0/+23 * Updated Japanese translation.Akira Tagoh2001-01-202-353/+277 * Use "Full Name <address>" for the label in the menu rather than theJeffrey Stedfast2001-01-202-1/+17 * Set the deleted bit *before* copying to the default folder, this way ifJeffrey Stedfast2001-01-202-4/+11 * If LISTing a subscribed folder doesn't return a LIST response, just ignoreDan Winship2001-01-202-3/+13 * (Adding a boolean "entry_changed" BonoboPropertyBag arg)Jason Leach2001-01-194-2/+64 * Updated russian translation.Valek Frob2001-01-192-2005/+2774 * create a new cal component alarm (cal_component_add_alarm): add alarm toJP Rosevear2001-01-1912-504/+688 * Missing Changelog entryJP Rosevear2001-01-191-0/+8 * add -ve sign to output of duration if appropriate.JP Rosevear2001-01-191-5/+25 * Changed a leftover $with_x_mailer to $with_sub_version. Made it so that ifJason Leach2001-01-192-2/+15 * Mark strings for translation.Kjartan Maraas2001-01-192-2/+6 * Norwegian translationKjartan Maraas2001-01-191-0/+2 * always free the delivery elements and correct embarrassingly stupid memoryJP Rosevear2001-01-193-16/+29 * typo fixesJacob Leach2001-01-191-4/+3 * (Bug #883: Shortcut bar does not update when a folders display nameJason Leach2001-01-199-3/+311 * More of Megan's revisions, and Field Chooser functions in the SortAaron Weber2001-01-1912-484/+580 * Do most of the work to get Grouping working, by reusing massive ammountsMiguel de Icaza2001-01-194-185/+282 * New swanky send/recieve thingy, well it so far only receives (pop/mbox).Not Zed2001-01-194-0/+617 * Add a percentage complete indicator to the status thing.Not Zed2001-01-193-18/+33 * Added a temporary button to test new receive code.Not Zed2001-01-192-0/+11 * Keep track of the valid column names (not used right now).Miguel de Icaza2001-01-195-157/+260 * Fixed text misplacement.Christopher James Lahey2001-01-191-10/+12 * Added Next/Previous toolbar buttons.Jeffrey Stedfast2001-01-192-0/+12 * Added the next/previous toolbar buttons.Jeffrey Stedfast2001-01-194-0/+37 * New function, name describes it well. (gtk_radio_button_select_nth): NewJason Leach2001-01-193-0/+65 * More tweaking... skip separator characters after the namespace character.Dan Winship2001-01-193-3/+19 * Oops. Somewhere in one of the reorgs, the code to add new messages to theDan Winship2001-01-192-1/+8 * Um, why was the doc directory removed from SUBDIRS?Federico Mena Quintero2001-01-194-38/+42 * Make zero the minimum number of days that can be specified.Federico Mena Quintero2001-01-192-5/+18 * Made it return a gboolean; it was completely ignoring the return valueFederico Mena Quintero2001-01-193-5/+11 * Return a success value. (setup_pas): Likewise. (setup_config): Likewise.Federico Mena Quintero2001-01-192-22/+49 * New files with a simple sequence to migrate the task components from theFederico Mena Quintero2001-01-1914-1426/+414 * Disconnect from the etss->source's signals *before* we unref it.Federico Mena Quintero2001-01-192-10/+22 * Make tooltip appear properly even if anchor is set.Christopher James Lahey2001-01-181-1/+1 * Center text vertically.Christopher James Lahey2001-01-181-10/+13 * Updated Norwegian (bokmål) translation. Removed old script.Kjartan Maraas2001-01-183-2195/+3031 * New function. (update_sort_config_dialog): Massive update to thisMiguel de Icaza2001-01-185-26/+230 * Er, don't set the button insensitive if there is *1* action, set itJeffrey Stedfast2001-01-182-4/+15 * ellipses for menu items that need dialogs.Jacob Leach2001-01-181-1/+1 * Updated to reflect changes to e_msg_composer_hdrs_get_from().Jeffrey Stedfast2001-01-184-30/+37 * Use static libcomposer.a here instead of the libtoolized one.Miguel de Icaza2001-01-181-1/+1 * Make the composer a standard library, not a libtool one. Nobody ever usesMiguel de Icaza2001-01-182-3/+8 * Removed addressbook/gui/widgets/test-minicard-view.c,Dave Camp2001-01-1828-71842/+55550 * (Bug #1192: Set the Composer window title to something useful)Jason Leach2001-01-184-8/+65 * Add some g_warnings() to help debug later if I ever get the segfaults IJeffrey Stedfast2001-01-183-4/+16 * Make sure that the message-info is non-null before we go accessing innerJeffrey Stedfast2001-01-182-1/+10 * oops, don't xexpand, that makes the dialog too wide.Jeffrey Stedfast2001-01-182-104/+104 * backed out Anna's dialog, no one likes it!Jeffrey Stedfast2001-01-182-1190/+1263 * New smtp error-code to string mapping function. (smtp_connect): Use theJeffrey Stedfast2001-01-182-10/+106 * Made EEntry be shrinkable.Christopher James Lahey2001-01-181-3/+6 * Make justification work properly for entries. Documented.Christopher James Lahey2001-01-182-2/+50 * get rid of some gtk warnings.Jeffrey Stedfast2001-01-181-6/+10 * Anna's dialog now supports SSL so we can get rid of the ssl-supportJeffrey Stedfast2001-01-185-1283/+1250 * Use "typedef enum { ... } Blah;" instead of "typedef enum _Blah Blah; enumFederico Mena Quintero2001-01-1810-105/+100 * Added a collection argument to this to set the GalViewCollection.Christopher James Lahey2001-01-1811-36/+315 * add evolution-gnomecard-importer.Larry Ewing2001-01-182-0/+3 * add the doc/devel/importer/Makefile as a target.Larry Ewing2001-01-184-2/+16 * New config function to set the path to the pgp binary.Jeffrey Stedfast2001-01-18