src/xcalls/x_pthread_mutex_unlock.c

Go to the documentation of this file.
00001 
00007 #include <pthread.h>
00008 #include <core/tx.h>
00009 #include <core/config.h>
00010 #include <core/txdesc.h>
00011 #include <misc/debug.h>
00012 #include <misc/errno.h>
00013 #include <xcalls/xcalls.h>
00014 
00015 typedef struct x_commit_args_s x_commit_args_t;
00016 
00017 struct x_commit_args_s {
00018         pthread_mutex_t *mutex;
00019 };
00020 
00021 static
00022 void
00023 x_pthread_mutex_unlock_commit(void *args, int *result)
00024 {
00025         x_commit_args_t *args_commit = (x_commit_args_t *) args;
00026         int             local_result = 0;
00027         int             ret;
00028 
00029         if ((ret = pthread_mutex_unlock(args_commit->mutex)) != 0) {
00030                 local_result = ret;
00031         }
00032         if (result) {
00033                 *result = local_result;
00034         }       
00035 }
00036 
00037 
00052 int
00053 XCALL_DEF(x_pthread_mutex_unlock)(pthread_mutex_t *mutex, int *result) 
00054 {
00055         txc_tx_t        *txd;
00056         int             ret;
00057         x_commit_args_t *args_commit; 
00058         int             local_result = 0;
00059 
00060         txd = txc_tx_get_txd();
00061 
00062         switch(txc_tx_get_xactstate(txd)) {
00063                 case TXC_XACTSTATE_TRANSACTIONAL_RETRYABLE:
00064                         args_commit = (x_commit_args_t *)
00065                                     txc_buffer_linear_malloc(txd->buffer_linear, 
00066                                                              sizeof(x_commit_args_t));
00067                         if (args_commit == NULL) {
00068                                 TXC_INTERNALERROR("Allocation failed. Linear buffer out of space.\n");
00069                         }
00070                         args_commit->mutex = mutex;
00071                         txc_tx_register_commit_action(txd, x_pthread_mutex_unlock_commit, 
00072                                                       (void *) args_commit, result,
00073                                                       TXC_TX_REGULAR_COMMIT_ACTION_ORDER);
00074                         ret = 0;
00075                         break;
00076                 case TXC_XACTSTATE_TRANSACTIONAL_IRREVOCABLE:
00077                 case TXC_XACTSTATE_NONTRANSACTIONAL:
00078                         if ((ret = pthread_mutex_unlock(mutex)) != 0) { 
00079                                 local_result = ret;
00080                                 goto done;
00081                         }
00082         }
00083 done:
00084         if (result) {
00085                 *result = local_result;
00086         }
00087         return ret;
00088 }

Generated on Wed Dec 9 20:32:39 2009 for xCalls by  doxygen 1.4.7