Commit Graph

55 Commits

Author SHA1 Message Date
Jan Friesse
c4cb9ae4f0 Fix OBJDB locking
Patch fixes following situation:

1. objdb receives reload notification and ends in function
object_reload_config. This will call objdb_wrlock. I will call this
thread #1

2. Another thread will decide to update corosync statistics and calls
object_key_increment. This calls objdb_rdlock. This thread is #2. But
because condition (lock_thread != pthread_self()) is satisfied, it will
also calls pthread_rwlock_rdlock. This will blocks, because thread #1
holds the lock.

3. object_reload_config will call reload functions (as real example
xml2objdb). xml2objdb needs to calls object_create. This calls
objdb_rdlock, but will hang on pthread_mutex_lock(&meta_lock), because
this lock is held by thread #2.

-> deadlock

It is handled by using recursive mutex.

Also every function is now really locked.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2963 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-06-28 13:32:56 +00:00
Christine Caulfield
bc1cca69b3 object_key_iter() calls object_key_iter_typed() and then always tries to
dereference the string it returns, even if the call fails. The attached
patch fixes this. 



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2944 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-06-15 15:48:58 +00:00
Jan Friesse
12c5f31a89 Handle some valgrind errors
- Memset for res_setup variable in coroipcs:req_setup_send
- Two memset in logsys for buffers
- Problem in corosync_totem_stats_updater where avg_token_holdtime has
size of avg_backlog_calc
- corosync_totem_stats_init where avg_backlog_calc is 32 bits (not 64)
- objdb problem if new_valie_len != object->value_len. In such case
newly allocated memory is not initialized and in some situations,
value_len is not updated.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2787 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-04-23 08:03:05 +00:00
Angus Salkeld
805a0f3c1d objdb: fix key change notifications
1) don't send notifications if the key is the same.
2) Add key value change notifications to key_inc & key_dec



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2746 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-03-30 07:19:25 +00:00
Christine Caulfield
576614109e Fix a couple of small bugs that happen when the configuration is reloaded.
1. the reload callback was not sent to the library,
2. totem exponentially added new callbacks because the old ones were not
   removed properly.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2684 fd59a12c-fef9-0310-b244-a6a79926bd2f
2010-03-16 09:53:18 +00:00
Angus Salkeld
acf9a8d85f Correct some ugly indentation.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2563 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-12-03 18:13:52 +00:00
Angus Salkeld
b63c2c27b6 objdb: fix memory leaks when objects are destroyed.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2562 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-12-03 08:36:31 +00:00
Angus Salkeld
663f894498 make sure key_names past from confdb are null terminated.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2561 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-12-02 22:14:00 +00:00
Angus Salkeld
e66297a886 Test the key value size for typed keys.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2513 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-10-11 23:46:07 +00:00
Angus Salkeld
0c9a6c49ff teach object_key_increment() key types.
This is so we can increment all integer types correctly.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2512 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-10-11 22:53:13 +00:00
Angus Salkeld
73b7aa19bb Add value types to objdb keys.
This allows you to create a key with a know type.
And then get the type with the key value.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2511 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-10-10 03:20:38 +00:00
Christine Caulfield
27b55337ce This patch makes a copy of the notifications list before calling the
reload_notifications callbacks. This allows callback functions to 
manipulate the notifications list without causing corruption or strange 
loops.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2380 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-08-04 07:14:55 +00:00
Steven Dake
ae5895c3f7 Call initializer directly for broken platforms which don't honor ctors in the shared object on dlopen.
This could probably be more tidy to detect those OS platforms which don't do this instead of hardcoding
to a specific platform we intend to port to.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2221 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-06-07 07:47:10 +00:00
Steven Dake
1beb0c1fbd Remove saHandleXXX and friends and use hdb instead.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2125 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-22 17:43:54 +00:00
Steven Dake
8126cf7458 Reworking of include file dependencies.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2119 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-22 09:01:30 +00:00
Steven Dake
ac597689df Remove warnings about objdb that casts a const char * to a char *.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2081 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-18 07:21:35 +00:00
Steven Dake
9141188ee8 Add spin locks for critical sections in hdb api.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2050 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-10 02:24:01 +00:00
Jim Meyering
8ef14f11eb cpg.h, objdb.h, coroaph.h: more const/size_t
* include/corosync/cpg.h (cpg_callbacks_t):
* include/corosync/mar_cpg.h (marshall_to_mar_cpg_name_t):
* lib/cpg.c (cpg_join, cpg_leave):
* lib/cpg.c (cpg_mcast_joined): make iovec const.
* include/corosync/cpg.h (cpg_mcast_joined): update prototype
...

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2048 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-09 20:53:03 +00:00
Jim Meyering
00db317b82 sync the rest of the code with previous header changes
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2042 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-08 17:29:37 +00:00
Jim Meyering
51cad562ae add "void" parameter list to avoid "isn't prototype" warning
* exec/objdb.c (objdb_wrlock, objdb_rdlock, objdb_rdunlock):
(objdb_wrunlock):
* services/cfg.c (send_shutdown, check_shutdown_status):
* services/votequorum.c (send_expectedvotes_notification):
* tools/corosync-cfgtool.c (shutdown_do):

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1977 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-04-01 09:32:32 +00:00
Jim Meyering
87b6a141ff * exec/objdb.c (object_create): make "object_name" param const
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1930 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-30 21:11:25 +00:00
Jim Meyering
b107445d5a objdb.c, etc: add "const" to avoid warnings
* exec/objdb.c:
* include/corosync/engine/coroapi.h:
* include/corosync/engine/objdb.h:

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1928 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-30 21:11:09 +00:00
Fabio M. Di Nitto
031c02f589 - Every .c file should include "config.h" to get the right defines...
- services/Makefile.am: add include search paths for config.h

- include/corosync/cs_config.h.in exports LCRSODIR and SOCKETDIR

- tools/Makefile.am: drop -D defines for dirs that are now in
cs_config.h or config.h

- configure.ac: sanitize prefix and exec_prefix paths. Export DIRS in
*config.h

- lib/Makefile.am: : drop -D defines for dirs that are now in
cs_config.h or config.h. Add rule to build lcr_ifact.o or building from
lib/ fails miserably



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1877 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-19 12:58:53 +00:00
Steven Dake
2a4c53dc1b Fix several errors in objdb notification handling, hdb_handle_t type
conversion errors, indentation, and do hdb_handle_put after instance 
data is used instead of before.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1841 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-03-11 23:09:04 +00:00
Christine Caulfield
d604803280 The current object database allows duplicate key names per object. This
is a bit of a nightmare to manage and provides no useful functionality
that I can see. Making keys unique has been discussed on IRC several
times and there seem to be no objections...so here is the patch:

Note that I have removed some now-useless parameters from the objdb API
too.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1783 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-02-26 14:49:41 +00:00
Steven Dake
58ab8d4a65 Unification around hdb_handle_t data type.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1782 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-02-25 11:14:47 +00:00
Christine Caulfield
98cc132d48 Fix a couple of memory leaks
The objdb occurred because object_find_destroy wasn't implemented!
 
The one in confdb occurred because object_find_destroy wasn't called if
object_find_next returned an error the first time it was invoked (ie
there were no subobjects).



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1741 fd59a12c-fef9-0310-b244-a6a79926bd2f
2009-01-23 15:41:06 +00:00
Angus Salkeld
aec3b38cde Fix coverity bug ID 1: overused local variable
coverity says that in exec/objdb.c: 1075 the found is always == 1
therefore the code is dead.  But this is just a case of an overused
local variable. "found" is used for two different searches.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1716 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-12-28 09:05:05 +00:00
Angus Salkeld
3bc868eb54 Fix a memory violation in objdb (caught by valgrind)
If the new length is larger then memory will be overwritten.

I could make this ">=" but we can save memory if the new size is smaller by using "!=".



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1680 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-10-30 19:32:23 +00:00
Christine Caulfield
44eaef35e0 Currently if a reload operation fails, any subsystems listening for
notifications will get a RELOAD_NOTIFY_START callback but not a
RELOAD_NOTIFY_END callback.

This patch adds a RELOAD_NOTIFY_FAILED callback so that interested
parties will know when the reload has finished and that it failed.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1678 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-10-27 08:25:53 +00:00
Christine Caulfield
f1764d1f56 Add locking around objdb calls so that reloads and writes are atomic.
Also add a notification callback for reload. Both the start and the stop
are notified so that the user can decide what to do with the flurry of 
updates that occur.

Note than the reload callback notification MUST be registered against
OBJECT_PARENT_HANDLE. Registering it lower down the hierarchy makes no sense.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1673 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-10-06 12:14:40 +00:00
Christine Caulfield
a7885395d2 Reinstate key_iter_reset that got removed by mistake in 1660
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1663 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-09-03 10:01:31 +00:00
Christine Caulfield
1d2d771f99 This patch adds key_increment and key_decrement calls to the objdb and
confdb subsystems.

This is useful to provide atomic counters (ag handle numbers) for
long-running (though not persistent) connections. It's not currently
possible via confdb to atomically get a new number from objdb due to the
lack of locking. Doing it via increment operations in the IPC thread
provides enough atomicity to make it useful. Fabio has already
identified a use for these calls.

It could also provide some form of basic co-operative locking mechanism
for IPC-using processes (not direct objdb calls).



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1662 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-09-03 07:58:08 +00:00
Christine Caulfield
2bab5b36cc Remove the disliked *_from calls from the objdb and recast
the confdb library to use the new find_create/find_next/find_destroy API
calls instead.

I've kept the libcondfb API the same as before with the single change of
adding a confdb_object_find_destroy to tidy up the find handle after
use. If you don't call this then libcondfb will do it for you when
confdb_finalize is called.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1660 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-08-26 07:34:22 +00:00
Steven Dake
e1f531380a Revert patch 1633 which breaks build.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1636 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-08-14 16:44:26 +00:00
Steven Dake
c4a1c7eb96 Change all occurances of openais to corosync.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1633 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-08-14 16:04:01 +00:00
Fabien Thomas
0c92a5e564 reorganize include file to match installed tree to build openais without installing corosync; correct some warnings and error under FreeBSD and Darwin
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1632 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-08-14 14:59:50 +00:00
Fabio M. Di Nitto
e4cfe7eb21 Revert config_verifyconf logic that is unnecessary
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1631 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-08-14 12:05:39 +00:00
Fabio M. Di Nitto
010198fac4 Add support for reload operations within objdb and plugins.
Use a 2 phase "commit" operation:
1) Invoke verifyconfig that should catch the errors before the reload operation
2) Invoke reloadconfig that performs the operation and should _never_ fail

Implementation note: if step 2 fails, there is no fall back at the moment.

Fix the IPC table for confdb:
MESSAGE_REQ_CONFDB_XPATH_EVAL_EXPRESSION = 12 was added to include/ipc_confdb.h
without an associated call. Thanks Chrissie for spotting this.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1629 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-08-13 03:58:03 +00:00
Fabio M. Di Nitto
38f8abd072 objdb: change list_add to list_add_tail when adding keys and objects
service: change openais_service_unlink_all to deal with the new objdb order

cleanup a few whitespaces



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1627 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-08-12 08:41:09 +00:00
Steven Dake
225b183bcb Add callback notification about changes to the object db and confdb apis.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1625 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-08-05 16:34:14 +00:00
Steven Dake
617dbdf2f0 Split openais and corosync tree into two seperate repositories.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1622 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-08-05 13:23:46 +00:00
Steven Dake
46babc95ad Initial move of corosync and openais trees into seperate directories.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1582 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-07-21 07:59:08 +00:00
Steven Dake
46b0163813 Change all email addresses that were sdake@mvista.com to sdake@redhat.com.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1541 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-05-12 13:48:06 +00:00
Patrick Caulfield
87e7ea9c1e Add writeback call to objdb
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1530 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-04-30 15:32:04 +00:00
Steven Dake
37c7b6184b Fix build error.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1529 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-04-29 10:08:11 +00:00
Steven Dake
4ad44b9c86 load and unload service engines at runtime.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1528 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-04-28 16:25:47 +00:00
Patrick Caulfield
9ab240e478 Add confdb, a library to access the configuration object database.
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1516 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-04-16 12:07:05 +00:00
Patrick Caulfield
2846b57ea1 Add some new calls into objdb.
These allow replacing/removing keys, and deleting a whole object subtree,
iterator functions to enumerate all objects/keys on an object,
and a dump call for debugging.



git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1505 fd59a12c-fef9-0310-b244-a6a79926bd2f
2008-03-10 15:18:12 +00:00
Steven Dake
3c7f8b7c05 This patch reworks IPC to use threads instead of the main poll loop
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1011 fd59a12c-fef9-0310-b244-a6a79926bd2f
2006-04-27 01:39:10 +00:00