| |
@@ -1248,7 +1248,7 @@
|
| |
map_rdlock(void)
|
| |
{
|
| |
int lock_status;
|
| |
- int lock_count;
|
| |
+ int lock_count;
|
| |
int rc = 0;
|
| |
|
| |
if (rw_monitor_enabled() == MAP_MONITOR_DISABLED) {
|
| |
@@ -1260,63 +1260,63 @@
|
| |
|
| |
|
| |
lock_status = get_plugin_monitor_status();
|
| |
- lock_count = get_plugin_monitor_count();
|
| |
+ lock_count = get_plugin_monitor_count();
|
| |
|
| |
#if DEBUG_MAP_LOCK
|
| |
slapi_log_error(SLAPI_LOG_FATAL, "map_rdlock",
|
| |
- "thread_id = %p (call level = %d)\n", PR_GetCurrentThread(), wrap_get_call_level());
|
| |
+ "thread_id = %p (call level = %d)\n", (void *) PR_MyThreadId(), wrap_get_call_level());
|
| |
#endif
|
| |
if (lock_status == MAP_RWLOCK_UNINIT) {
|
| |
/* This is not initialized used the old way */
|
| |
slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
"map rdlock: old way lock_status == MAP_RWLOCK_UNINIT\n");
|
| |
return wrap_rwlock_rdlock(map_data.lock);
|
| |
- }
|
| |
+ }
|
| |
|
| |
- if (lock_status == MAP_RWLOCK_FREE) {
|
| |
- /* The plugin lock is free, acquire it */
|
| |
+ if (lock_status == MAP_RWLOCK_FREE) {
|
| |
+ /* The plugin lock is free, acquire it */
|
| |
#if DEBUG_MAP_LOCK
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
- "map rdlock: current lock_status == MAP_RWLOCK_FREE\n");
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
+ "map rdlock: current lock_status == MAP_RWLOCK_FREE\n");
|
| |
#endif
|
| |
- set_plugin_monitor_status(MAP_RLOCK_HELD);
|
| |
- set_plugin_monitor_count(1);
|
| |
+ set_plugin_monitor_status(MAP_RLOCK_HELD);
|
| |
+ set_plugin_monitor_count(1);
|
| |
#if DEBUG_MAP_LOCK
|
| |
- if (lock_count != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
- "map rdlock: (%p) ALERT !!! count was %d -> 1\n", PR_GetCurrentThread(), lock_count);
|
| |
- }
|
| |
+ if (lock_count != 0) {
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
+ "map rdlock: (%p) ALERT !!! count was %d -> 1\n", (void *) PR_MyThreadId(), lock_count);
|
| |
+ }
|
| |
#endif
|
| |
|
| |
- /* Acquire the slapi plugin in read */
|
| |
- rc = plugin_rdlock();
|
| |
- if (rc) {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
- "map rdlock: (%p) MAP_RWLOCK_FREE -> MAP_RLOCK_HELD: fail to read lock plugin lock (%d)\n", PR_GetCurrentThread(), rc);
|
| |
- return rc;
|
| |
- }
|
| |
+ /* Acquire the slapi plugin in read */
|
| |
+ rc = plugin_rdlock();
|
| |
+ if (rc) {
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
+ "map rdlock: (%p) MAP_RWLOCK_FREE -> MAP_RLOCK_HELD: fail to read lock plugin lock (%d)\n", (void *) PR_MyThreadId(), rc);
|
| |
+ return rc;
|
| |
+ }
|
| |
#if DEBUG_MAP_LOCK
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
- "map rdlock: (%p) MAP_RWLOCK_FREE -> MAP_RLOCK_HELD : count=%d\n", PR_GetCurrentThread(), 1);
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
+ "map rdlock: (%p) MAP_RWLOCK_FREE -> MAP_RLOCK_HELD : count=%d\n", (void *) PR_MyThreadId(), 1);
|
| |
#endif
|
| |
- rc = wrap_rwlock_rdlock(map_data.lock);
|
| |
- if (rc) {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
- "Fail to acquire map lock in read (%d)\n", rc);
|
| |
- plugin_unlock();
|
| |
- return rc;
|
| |
- }
|
| |
- return 0;
|
| |
- }
|
| |
+ rc = wrap_rwlock_rdlock(map_data.lock);
|
| |
+ if (rc) {
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
+ "Fail to acquire map lock in read (%d)\n", rc);
|
| |
+ plugin_unlock();
|
| |
+ return rc;
|
| |
+ }
|
| |
+ return 0;
|
| |
+ }
|
| |
|
| |
#if DEBUG_MAP_LOCK
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
- "map rdlock: (%p) was already hold %s : count=%d > %d!!!\n",
|
| |
- PR_GetCurrentThread(),
|
| |
- (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD": "MAP_RLOCK_HELD",
|
| |
- lock_count, lock_count + 1);
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
+ "map rdlock: (%p) was already hold %s : count=%d > %d!!!\n",
|
| |
+ (void *) PR_MyThreadId(),
|
| |
+ (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : "MAP_RLOCK_HELD",
|
| |
+ lock_count, lock_count + 1);
|
| |
#endif
|
| |
- set_plugin_monitor_count(lock_count + 1);
|
| |
+ set_plugin_monitor_count(lock_count + 1);
|
| |
return 0;
|
| |
}
|
| |
|
| |
@@ -1324,7 +1324,7 @@
|
| |
map_wrlock(void)
|
| |
{
|
| |
int lock_status;
|
| |
- int lock_count;
|
| |
+ int lock_count;
|
| |
int rc = 0;
|
| |
|
| |
if (rw_monitor_enabled() == MAP_MONITOR_DISABLED) {
|
| |
@@ -1335,11 +1335,11 @@
|
| |
}
|
| |
|
| |
lock_status = get_plugin_monitor_status();
|
| |
- lock_count = get_plugin_monitor_count();
|
| |
+ lock_count = get_plugin_monitor_count();
|
| |
|
| |
#if DEBUG_MAP_LOCK
|
| |
slapi_log_error(SLAPI_LOG_FATAL, "map wrlock",
|
| |
- "thread_id = %p (call level = %d)\n", PR_GetCurrentThread(), wrap_get_call_level());
|
| |
+ "thread_id = %p (call level = %d)\n", (void *) PR_MyThreadId(), wrap_get_call_level());
|
| |
#endif
|
| |
if (lock_status == MAP_RWLOCK_UNINIT) {
|
| |
/* This is not initialized used the old way */
|
| |
@@ -1356,65 +1356,65 @@
|
| |
"map wrlock: current lock_status == MAP_LOCK_FREE\n");
|
| |
#endif
|
| |
|
| |
- set_plugin_monitor_count(1);
|
| |
+ set_plugin_monitor_count(1);
|
| |
#if DEBUG_MAP_LOCK
|
| |
- if (lock_count != 0) {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
- "map wrlock: (%p) ALERT !!! count was %d --> 1\n", PR_GetCurrentThread(), lock_count);
|
| |
- }
|
| |
+ if (lock_count != 0) {
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
+ "map wrlock: (%p) ALERT !!! count was %d --> 1\n", (void *) PR_MyThreadId(), lock_count);
|
| |
+ }
|
| |
#endif
|
| |
- /* Acquire the slapi plugin in write */
|
| |
- rc = plugin_wrlock();
|
| |
- if (rc) {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
- "map wrlock: (%p) MAP_RWLOCK_FREE -> MAP_RLOCK_HELD: fail to read lock plugin lock (%d)\n", PR_GetCurrentThread(), rc);
|
| |
- return rc;
|
| |
- }
|
| |
+ /* Acquire the slapi plugin in write */
|
| |
+ rc = plugin_wrlock();
|
| |
+ if (rc) {
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schemacompat",
|
| |
+ "map wrlock: (%p) MAP_RWLOCK_FREE -> MAP_RLOCK_HELD: fail to read lock plugin lock (%d)\n", (void *) PR_MyThreadId(), rc);
|
| |
+ return rc;
|
| |
+ }
|
| |
#if DEBUG_MAP_LOCK
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
- "map wrlock: (%p) MAP_RWLOCK_FREE --> MAP_WLOCK_HELD : count=%d\n", PR_GetCurrentThread(), 1);
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
+ "map wrlock: (%p) MAP_RWLOCK_FREE --> MAP_WLOCK_HELD : count=%d\n", (void *) PR_MyThreadId(), 1);
|
| |
#endif
|
| |
|
| |
- rc = wrap_rwlock_wrlock(map_data.lock);
|
| |
- if (rc) {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
- "map wrlock: (%p) MAP_RWLOCK_FREE --> MAP_WLOCK_HELD : fail to write lock map lock (%d)\n", PR_GetCurrentThread(), rc);
|
| |
- plugin_unlock();
|
| |
- goto common;
|
| |
- }
|
| |
- } else {
|
| |
- set_plugin_monitor_count(lock_count + 1);
|
| |
+ rc = wrap_rwlock_wrlock(map_data.lock);
|
| |
+ if (rc) {
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
+ "map wrlock: (%p) MAP_RWLOCK_FREE --> MAP_WLOCK_HELD : fail to write lock map lock (%d)\n", (void *) PR_MyThreadId(), rc);
|
| |
+ plugin_unlock();
|
| |
+ goto common;
|
| |
+ }
|
| |
+ } else {
|
| |
+ set_plugin_monitor_count(lock_count + 1);
|
| |
#if DEBUG_MAP_LOCK
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
- "map wrlock: (%p) %s --> MAP_WLOCK_HELD : count=%d\n",
|
| |
- PR_GetCurrentThread(),
|
| |
- (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD": "MAP_RLOCK_HELD",
|
| |
- lock_count + 1);
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
+ "map wrlock: (%p) %s --> MAP_WLOCK_HELD : count=%d\n",
|
| |
+ (void *) PR_MyThreadId(),
|
| |
+ (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : "MAP_RLOCK_HELD",
|
| |
+ lock_count + 1);
|
| |
#endif
|
| |
|
| |
- if (lock_status == MAP_RLOCK_HELD) {
|
| |
- /* lock is already acquired in read */
|
| |
+ if (lock_status == MAP_RLOCK_HELD) {
|
| |
+ /* lock is already acquired in read */
|
| |
#if DEBUG_MAP_LOCK
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
- "map wrlock: weird situation map lock is held in read and now required in write mode\n");
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
+ "map wrlock: weird situation map lock is held in read and now required in write mode\n");
|
| |
#endif
|
| |
- /* First free the lock held in read */
|
| |
- rc = plugin_unlock();
|
| |
- if (rc) {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
- "map wrlock: fail to unlock plugin lock (%d)\n", rc);
|
| |
- goto common;
|
| |
- }
|
| |
+ /* First free the lock held in read */
|
| |
+ rc = plugin_unlock();
|
| |
+ if (rc) {
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
+ "map wrlock: fail to unlock plugin lock (%d)\n", rc);
|
| |
+ goto common;
|
| |
+ }
|
| |
|
| |
- /* Second acquire it in write */
|
| |
- rc = plugin_wrlock();
|
| |
- if (rc) {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
- "map wrlock: fail to write lock plugin lock (%d)\n", rc);
|
| |
- goto common;
|
| |
- }
|
| |
+ /* Second acquire it in write */
|
| |
+ rc = plugin_wrlock();
|
| |
+ if (rc) {
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
+ "map wrlock: fail to write lock plugin lock (%d)\n", rc);
|
| |
+ goto common;
|
| |
}
|
| |
}
|
| |
+ }
|
| |
|
| |
common:
|
| |
set_plugin_monitor_status(MAP_WLOCK_HELD);
|
| |
@@ -1425,7 +1425,7 @@
|
| |
map_unlock(void)
|
| |
{
|
| |
int lock_status;
|
| |
- int lock_count;
|
| |
+ int lock_count;
|
| |
int rc = 0;
|
| |
|
| |
if (rw_monitor_enabled() == MAP_MONITOR_DISABLED) {
|
| |
@@ -1436,11 +1436,11 @@
|
| |
}
|
| |
|
| |
lock_status = get_plugin_monitor_status();
|
| |
- lock_count = get_plugin_monitor_count();
|
| |
+ lock_count = get_plugin_monitor_count();
|
| |
|
| |
#if DEBUG_MAP_LOCK
|
| |
slapi_log_error(SLAPI_LOG_FATAL, "map_unlock",
|
| |
- "thread_id = %p (call level = %d)\n", PR_GetCurrentThread(), wrap_get_call_level());
|
| |
+ "thread_id = %p (call level = %d)\n", (void *) PR_MyThreadId(), wrap_get_call_level());
|
| |
#endif
|
| |
if (lock_status == MAP_RWLOCK_UNINIT) {
|
| |
/* This is not initialized used the old way */
|
| |
@@ -1448,48 +1448,48 @@
|
| |
"map_unlock: old way lock_status == MAP_RWLOCK_UNINIT\n");
|
| |
|
| |
return wrap_rwlock_unlock(map_data.lock);
|
| |
- }
|
| |
+ }
|
| |
|
| |
- if (lock_count == 1) {
|
| |
- set_plugin_monitor_status(MAP_RWLOCK_FREE);
|
| |
- rc = plugin_unlock();
|
| |
- if (rc) {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
- "map unlock: fail to unlock plugin lock (%d)\n", rc);
|
| |
- goto common;
|
| |
- }
|
| |
- #if DEBUG_MAP_LOCK
|
| |
+ if (lock_count == 1) {
|
| |
+ set_plugin_monitor_status(MAP_RWLOCK_FREE);
|
| |
+ rc = plugin_unlock();
|
| |
+ if (rc) {
|
| |
slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
- "map_unlock: (%p) %s --> MAP_RWLOCK_FREE : count=%d\n",
|
| |
- PR_GetCurrentThread(),
|
| |
- (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : (lock_status == MAP_RLOCK_HELD) ? "MAP_RLOCK_HELD" : "MAP_RWLOCK_FREE",
|
| |
- 0);
|
| |
+ "map unlock: fail to unlock plugin lock (%d)\n", rc);
|
| |
+ goto common;
|
| |
+ }
|
| |
+ #if DEBUG_MAP_LOCK
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
+ "map_unlock: (%p) %s --> MAP_RWLOCK_FREE : count=%d\n",
|
| |
+ (void *) PR_MyThreadId(),
|
| |
+ (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : (lock_status == MAP_RLOCK_HELD) ? "MAP_RLOCK_HELD" : "MAP_RWLOCK_FREE",
|
| |
+ 0);
|
| |
#endif
|
| |
- rc = wrap_rwlock_unlock(map_data.lock);
|
| |
- if (rc) {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
+ rc = wrap_rwlock_unlock(map_data.lock);
|
| |
+ if (rc) {
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
"map_unlock: fail to unlock map lock (%d)\n", rc);
|
| |
- goto common;
|
| |
- }
|
| |
+ goto common;
|
| |
}
|
| |
- if (lock_count >= 1) {
|
| |
- set_plugin_monitor_count(lock_count - 1);
|
| |
+ }
|
| |
+ if (lock_count >= 1) {
|
| |
+ set_plugin_monitor_count(lock_count - 1);
|
| |
#if DEBUG_MAP_LOCK
|
| |
- if (lock_count > 1) {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
- "map_unlock: (%p) keep %s : count=%d\n",
|
| |
- PR_GetCurrentThread(),
|
| |
- (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : (lock_status == MAP_RLOCK_HELD) ? "MAP_RLOCK_HELD" : "MAP_RWLOCK_FREE",
|
| |
- lock_count - 1);
|
| |
- } else {
|
| |
- slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
- "map_unlock: (%p) is now %s : count=%d\n",
|
| |
- PR_GetCurrentThread(),
|
| |
- "MAP_RWLOCK_FREE",
|
| |
- lock_count - 1);
|
| |
- }
|
| |
- #endif
|
| |
+ if (lock_count > 1) {
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
+ "map_unlock: (%p) keep %s : count=%d\n",
|
| |
+ (void *) PR_MyThreadId(),
|
| |
+ (lock_status == MAP_WLOCK_HELD) ? "MAP_WLOCK_HELD" : (lock_status == MAP_RLOCK_HELD) ? "MAP_RLOCK_HELD" : "MAP_RWLOCK_FREE",
|
| |
+ lock_count - 1);
|
| |
+ } else {
|
| |
+ slapi_log_error(SLAPI_LOG_FATAL, "schema-compat",
|
| |
+ "map_unlock: (%p) is now %s : count=%d\n",
|
| |
+ (void *) PR_MyThreadId(),
|
| |
+ "MAP_RWLOCK_FREE",
|
| |
+ lock_count - 1);
|
| |
}
|
| |
+ #endif
|
| |
+ }
|
| |
|
| |
common:
|
| |
return rc;
|
| |
This patch is composed of 3 patches: