Download | Plain Text | Line Numbers
--- a/lib/glibUtils/fileLogger.c 2012-11-01 00:59:53.000000000 +0100
+++ b/lib/glibUtils/fileLogger.c 2013-02-26 17:12:45.084792332 +0100
@@ -43,7 +43,7 @@
guint maxFiles;
gboolean append;
gboolean error;
- GStaticRWLock lock;
+ GRWLock rw_lock;
} FileLogger;
@@ -254,7 +254,7 @@
{
FileLogger *logger = data;
- g_static_rw_lock_reader_lock(&logger->lock);
+ g_rw_lock_reader_lock(&logger->rw_lock);
if (logger->error) {
goto exit;
@@ -265,13 +265,13 @@
* We need to drop the read lock and acquire a write lock to open
* the log file.
*/
- g_static_rw_lock_reader_unlock(&logger->lock);
- g_static_rw_lock_writer_lock(&logger->lock);
+ g_rw_lock_reader_unlock(&logger->rw_lock);
+ g_rw_lock_writer_lock(&logger->rw_lock);
if (logger->file == NULL) {
logger->file = FileLoggerOpen(data);
}
- g_static_rw_lock_writer_unlock(&logger->lock);
- g_static_rw_lock_reader_lock(&logger->lock);
+ g_rw_lock_writer_unlock(&logger->rw_lock);
+ g_rw_lock_reader_lock(&logger->rw_lock);
if (logger->file == NULL) {
logger->error = TRUE;
goto exit;
@@ -288,15 +288,15 @@
#endif
if (g_atomic_int_get(&logger->logSize) >= logger->maxSize) {
/* Drop the reader lock, grab the writer lock and re-check. */
- g_static_rw_lock_reader_unlock(&logger->lock);
- g_static_rw_lock_writer_lock(&logger->lock);
+ g_rw_lock_reader_unlock(&logger->rw_lock);
+ g_rw_lock_writer_lock(&logger->rw_lock);
if (g_atomic_int_get(&logger->logSize) >= logger->maxSize) {
fclose(logger->file);
logger->append = FALSE;
logger->file = FileLoggerOpen(logger);
}
- g_static_rw_lock_writer_unlock(&logger->lock);
- g_static_rw_lock_reader_lock(&logger->lock);
+ g_rw_lock_writer_unlock(&logger->rw_lock);
+ g_rw_lock_reader_lock(&logger->rw_lock);
} else {
fflush(logger->file);
}
@@ -306,7 +306,7 @@
}
exit:
- g_static_rw_lock_reader_unlock(&logger->lock);
+ g_rw_lock_reader_unlock(&logger->rw_lock);
}
@@ -328,7 +328,7 @@
if (logger->file != NULL) {
fclose(logger->file);
}
- g_static_rw_lock_free(&logger->lock);
+ g_rw_lock_clear(&logger->rw_lock);
g_free(logger->path);
g_free(logger);
}
@@ -375,7 +375,7 @@
data->append = append;
data->maxSize = maxSize * 1024 * 1024;
data->maxFiles = maxFiles + 1; /* To account for the active log file. */
- g_static_rw_lock_init(&data->lock);
+ g_rw_lock_init(&data->rw_lock);
return &data->handler;
}
--- a/lib/rpcChannel/bdoorChannel.c 2012-11-01 00:58:56.000000000 +0100
+++ b/lib/rpcChannel/bdoorChannel.c 2013-02-26 17:20:12.386291149 +0100
@@ -34,7 +34,7 @@
typedef struct BackdoorChannel {
GMainContext *mainCtx;
- GStaticMutex outLock;
+ GMutex outLock;
RpcIn *in;
RpcOut *out;
gboolean inStarted;
@@ -119,7 +119,7 @@
{
BackdoorChannel *bdoor = chan->_private;
- g_static_mutex_lock(&bdoor->outLock);
+ g_mutex_lock(&bdoor->outLock);
if (bdoor->out != NULL) {
if (bdoor->outStarted) {
RpcOut_stop(bdoor->out);
@@ -128,7 +128,7 @@
} else {
ASSERT(!bdoor->outStarted);
}
- g_static_mutex_unlock(&bdoor->outLock);
+ g_mutex_unlock(&bdoor->outLock);
if (bdoor->in != NULL) {
if (bdoor->inStarted) {
@@ -158,7 +158,7 @@
RpcIn_Destruct(bdoor->in);
}
RpcOut_Destruct(bdoor->out);
- g_static_mutex_free(&bdoor->outLock);
+ g_mutex_clear(&bdoor->outLock);
if (bdoor->mainCtx != NULL) {
g_main_context_unref(bdoor->mainCtx);
}
@@ -190,7 +190,7 @@
size_t replyLen;
BackdoorChannel *bdoor = chan->_private;
- g_static_mutex_lock(&bdoor->outLock);
+ g_mutex_lock(&bdoor->outLock);
if (!bdoor->outStarted) {
goto exit;
}
@@ -248,7 +248,7 @@
}
exit:
- g_static_mutex_unlock(&bdoor->outLock);
+ g_mutex_unlock(&bdoor->outLock);
return ret;
}
@@ -268,7 +268,7 @@
ret = RpcChannel_Create();
bdoor = g_malloc0(sizeof *bdoor);
- g_static_mutex_init(&bdoor->outLock);
+ g_mutex_init(&bdoor->outLock);
bdoor->out = RpcOut_Construct();
ASSERT(bdoor->out != NULL);
--- a/libvmtools/i18n.c 2013-02-26 16:57:40.149995816 +0100
+++ b/libvmtools/i18n.c 2013-02-26 17:20:35.740847258 +0100
@@ -54,7 +54,7 @@
typedef struct MsgState {
HashTable *domains; /* List of text domains. */
- GStaticMutex lock; /* Mutex to protect shared state. */
+ GMutex lock; /* Mutex to protect shared state. */
} MsgState;
@@ -132,7 +132,7 @@
{
ASSERT(gMsgState == NULL);
gMsgState = g_new0(MsgState, 1);
- g_static_mutex_init(&gMsgState->lock);
+ g_mutex_init(&gMsgState->lock);
return NULL;
}
@@ -343,7 +343,7 @@
* This lock is pretty coarse-grained, but a lot of the code below just runs
* in exceptional situations, so it should be OK.
*/
- g_static_mutex_lock(&state->lock);
+ g_mutex_lock(&state->lock);
catalog = MsgGetCatalog(domain);
if (catalog != NULL) {
@@ -414,7 +414,7 @@
}
}
- g_static_mutex_unlock(&state->lock);
+ g_mutex_unlock(&state->lock);
return strp;
}
@@ -681,7 +681,7 @@
if (gMsgState->domains != NULL) {
HashTable_Free(gMsgState->domains);
}
- g_static_mutex_free(&gMsgState->lock);
+ g_mutex_clear(&gMsgState->lock);
g_free(gMsgState);
}
}
@@ -774,9 +774,9 @@
"catalog dir '%s'.\n", domain, lang, catdir);
}
} else {
- g_static_mutex_lock(&state->lock);
+ g_mutex_lock(&state->lock);
MsgSetCatalog(domain, catalog);
- g_static_mutex_unlock(&state->lock);
+ g_mutex_unlock(&state->lock);
}
g_free(file);
free(dfltdir);
--- a/libvmtools/vmxLogger.c 2012-11-01 00:58:28.000000000 +0100
+++ b/libvmtools/vmxLogger.c 2013-02-26 17:20:21.628115494 +0100
@@ -27,7 +27,7 @@
typedef struct VMXLoggerData {
GlibLogger handler;
- GStaticMutex lock;
+ GMutex lock;
RpcChannel *chan;
} VMXLoggerData;
@@ -60,7 +60,7 @@
{
VMXLoggerData *logger = data;
- g_static_mutex_lock(&logger->lock);
+ g_mutex_lock(&logger->lock);
if (RpcChannel_Start(logger->chan)) {
gchar *msg;
gint cnt = VMToolsAsprintf(&msg, "log %s", message);
@@ -75,7 +75,7 @@
g_free(msg);
RpcChannel_Stop(logger->chan);
}
- g_static_mutex_unlock(&logger->lock);
+ g_mutex_unlock(&logger->lock);
}
@@ -95,7 +95,7 @@
{
VMXLoggerData *logger = data;
RpcChannel_Destroy(logger->chan);
- g_static_mutex_free(&logger->lock);
+ g_mutex_clear(&logger->lock);
g_free(logger);
}
@@ -119,7 +119,7 @@
data->handler.addsTimestamp = TRUE;
data->handler.shared = TRUE;
data->handler.dtor = VMXLoggerDestroy;
- g_static_mutex_init(&data->lock);
+ g_mutex_init(&data->lock);
data->chan = BackdoorChannel_New();
return &data->handler;
}
--- a/services/vmtoolsd/mainLoop.c 2012-11-01 00:58:56.000000000 +0100
+++ b/services/vmtoolsd/mainLoop.c 2013-02-26 03:08:39.640930774 +0100
@@ -376,10 +376,6 @@
GMainContext *gctx;
ToolsServiceProperty ctxProp = { TOOLS_CORE_PROP_CTX };
- if (!g_thread_supported()) {
- g_thread_init(NULL);
- }
-
ToolsCore_ReloadConfig(state, FALSE);
/* Initializes the app context. */
--- a/services/vmtoolsd/serviceObj.c 2012-11-01 00:58:56.000000000 +0100
+++ b/services/vmtoolsd/serviceObj.c 2013-02-26 17:20:39.979766691 +0100
@@ -180,14 +180,14 @@
id -= 1;
- g_mutex_lock(self->lock);
+ g_mutex_lock(&self->lock);
if (id < self->props->len) {
ServiceProperty *p = &g_array_index(self->props, ServiceProperty, id);
g_value_set_pointer(value, p->value);
}
- g_mutex_unlock(self->lock);
+ g_mutex_unlock(&self->lock);
}
@@ -217,14 +217,14 @@
id -= 1;
- g_mutex_lock(self->lock);
+ g_mutex_lock(&self->lock);
if (id < self->props->len) {
p = &g_array_index(self->props, ServiceProperty, id);
p->value = g_value_get_pointer(value);
}
- g_mutex_unlock(self->lock);
+ g_mutex_unlock(&self->lock);
if (p != NULL) {
g_object_notify(object, p->name);
@@ -260,7 +260,7 @@
params);
self = TOOLSCORE_SERVICE(object);
- self->lock = g_mutex_new();
+ g_mutex_init(&self->lock);
self->props = g_array_new(FALSE, FALSE, sizeof (ServiceProperty));
return object;
@@ -296,7 +296,7 @@
}
g_array_free(self->props, TRUE);
- g_mutex_free(self->lock);
+ g_mutex_clear(&self->lock);
}
@@ -459,7 +459,7 @@
prop->name,
G_PARAM_READWRITE);
- g_mutex_lock(obj->lock);
+ g_mutex_lock(&obj->lock);
sprop.id = ++PROP_ID_SEQ;
sprop.name = g_strdup(prop->name);
@@ -467,6 +467,6 @@
g_array_append_val(obj->props, sprop);
g_object_class_install_property(G_OBJECT_CLASS(klass), sprop.id, pspec);
- g_mutex_unlock(obj->lock);
+ g_mutex_unlock(&obj->lock);
}
--- a/services/vmtoolsd/serviceObj.h 2012-11-01 00:58:56.000000000 +0100
+++ b/services/vmtoolsd/serviceObj.h 2013-02-26 17:06:07.693344949 +0100
@@ -39,7 +39,7 @@
typedef struct ToolsCoreService {
GObject parent;
- GMutex *lock;
+ GMutex lock;
GArray *props;
} ToolsCoreService;
--- a/services/vmtoolsd/threadPool.c 2012-11-01 00:58:56.000000000 +0100
+++ b/services/vmtoolsd/threadPool.c 2013-02-26 17:20:45.088669587 +0100
@@ -40,7 +40,7 @@
GThreadPool *pool;
GQueue *workQueue;
GPtrArray *threads;
- GMutex *lock;
+ GMutex lock;
guint nextWorkId;
} ThreadPoolState;
@@ -170,9 +170,9 @@
* In multi-threaded mode, the thread pool callback already did this.
*/
if (gState.pool == NULL) {
- g_mutex_lock(gState.lock);
+ g_mutex_lock(&gState.lock);
g_queue_remove(gState.workQueue, work);
- g_mutex_unlock(gState.lock);
+ g_mutex_unlock(&gState.lock);
}
work->cb(gState.ctx, work->data);
@@ -223,7 +223,7 @@
task->cb(gState.ctx, task->data);
task->active = FALSE;
- g_mutex_lock(gState.lock);
+ g_mutex_lock(&gState.lock);
/* If not active, the shutdown function will clean things up. */
if (gState.active) {
g_ptr_array_remove(gState.threads, task);
@@ -232,7 +232,7 @@
task,
ToolsCorePoolDestroyThread);
}
- g_mutex_unlock(gState.lock);
+ g_mutex_unlock(&gState.lock);
return NULL;
}
@@ -257,9 +257,9 @@
{
WorkerTask *work;
- g_mutex_lock(gState.lock);
+ g_mutex_lock(&gState.lock);
work = g_queue_pop_tail(gState.workQueue);
- g_mutex_unlock(gState.lock);
+ g_mutex_unlock(&gState.lock);
ASSERT(work != NULL);
@@ -300,7 +300,7 @@
task->data = data;
task->dtor = dtor;
- g_mutex_lock(gState.lock);
+ g_mutex_lock(&gState.lock);
if (!gState.active) {
g_free(task);
@@ -351,7 +351,7 @@
ToolsCorePoolDestroyTask);
exit:
- g_mutex_unlock(gState.lock);
+ g_mutex_unlock(&gState.lock);
return id;
}
@@ -378,7 +378,7 @@
g_return_if_fail(id != 0);
- g_mutex_lock(gState.lock);
+ g_mutex_lock(&gState.lock);
if (!gState.active) {
goto exit;
}
@@ -390,7 +390,7 @@
}
exit:
- g_mutex_unlock(gState.lock);
+ g_mutex_unlock(&gState.lock);
if (task != NULL) {
if (task->srcId > 0) {
@@ -431,7 +431,7 @@
GError *err = NULL;
StandaloneTask *task = NULL;
- g_mutex_lock(gState.lock);
+ g_mutex_lock(&gState.lock);
if (!gState.active) {
goto exit;
}
@@ -442,7 +442,7 @@
task->interrupt = interrupt;
task->data = data;
task->dtor = dtor;
- task->thread = g_thread_create(ToolsCorePoolRunThread, task, TRUE, &err);
+ task->thread = g_thread_try_new("tasks", ToolsCorePoolRunThread, task, &err);
if (err == NULL) {
g_ptr_array_add(gState.threads, task);
@@ -454,7 +454,7 @@
}
exit:
- g_mutex_unlock(gState.lock);
+ g_mutex_unlock(&gState.lock);
return task != NULL;
}
@@ -526,7 +526,7 @@
}
gState.active = TRUE;
- gState.lock = g_mutex_new();
+ g_mutex_init(&gState.lock);
gState.threads = g_ptr_array_new();
gState.workQueue = g_queue_new();
@@ -553,9 +553,9 @@
{
guint i;
- g_mutex_lock(gState.lock);
+ g_mutex_lock(&gState.lock);
gState.active = FALSE;
- g_mutex_unlock(gState.lock);
+ g_mutex_unlock(&gState.lock);
/* Notify all spawned threads to stop. */
for (i = 0; i < gState.threads->len; i++) {
@@ -589,7 +589,7 @@
/* Cleanup. */
g_ptr_array_free(gState.threads, TRUE);
g_queue_free(gState.workQueue);
- g_mutex_free(gState.lock);
+ g_mutex_clear(&gState.lock);
memset(&gState, 0, sizeof gState);
g_object_set(ctx->serviceObj, TOOLS_CORE_PROP_TPOOL, NULL, NULL);
}