@@ -33,7 +33,6 @@ static char* dtm_unix_sock_dir;
3333
3434typedef unsigned xid_t ;
3535
36- // Connects to the specified DTM.
3736static DTMConn DtmConnect (char * host , int port )
3837{
3938 DTMConn dtm ;
@@ -297,10 +296,6 @@ void DtmInitSnapshot(Snapshot snapshot)
297296 #endif
298297}
299298
300- // Starts a new global transaction of nParticipants size. Returns the
301- // transaction id, fills the 'snapshot' and 'gxmin' on success. 'gxmin' is the
302- // smallest xmin among all snapshots known to DTM. Returns INVALID_XID
303- // otherwise.
304299TransactionId DtmGlobalStartTransaction (Snapshot snapshot , TransactionId * gxmin )
305300{
306301 int i ;
@@ -337,8 +332,6 @@ TransactionId DtmGlobalStartTransaction(Snapshot snapshot, TransactionId *gxmin)
337332 return INVALID_XID ;
338333}
339334
340- // Asks the DTM for a fresh snapshot. Fills the 'snapshot' and 'gxmin' on
341- // success. 'gxmin' is the smallest xmin among all snapshots known to DTM.
342335void DtmGlobalGetSnapshot (TransactionId xid , Snapshot snapshot , TransactionId * gxmin )
343336{
344337 int i ;
@@ -376,10 +369,6 @@ void DtmGlobalGetSnapshot(TransactionId xid, Snapshot snapshot, TransactionId *g
376369 );
377370}
378371
379- // Commits transaction only once all participants have called this function,
380- // does not change CLOG otherwise. Set 'wait' to 'true' if you want this call
381- // to return only after the transaction is considered finished by the DTM.
382- // Returns the status on success, or -1 otherwise.
383372XidStatus DtmGlobalSetTransStatus (TransactionId xid , XidStatus status , bool wait )
384373{
385374 int reslen ;
@@ -424,9 +413,6 @@ XidStatus DtmGlobalSetTransStatus(TransactionId xid, XidStatus status, bool wait
424413 return -1 ;
425414}
426415
427- // Gets the status of the transaction identified by 'xid'. Returns the status
428- // on success, or -1 otherwise. If 'wait' is true, then it does not return
429- // until the transaction is finished.
430416XidStatus DtmGlobalGetTransStatus (TransactionId xid , bool wait )
431417{
432418 int reslen ;
@@ -462,11 +448,6 @@ XidStatus DtmGlobalGetTransStatus(TransactionId xid, bool wait)
462448 return -1 ;
463449}
464450
465- // Reserves at least 'nXids' successive xids for local transactions. The xids
466- // reserved are not less than 'xid' in value. Returns the actual number of xids
467- // reserved, and sets the 'first' xid accordingly. The number of xids reserved
468- // is guaranteed to be at least nXids.
469- // In other words, *first ≥ xid and result ≥ nXids.
470451int DtmGlobalReserve (TransactionId xid , int nXids , TransactionId * first )
471452{
472453 xid_t xmin , xmax ;
@@ -503,11 +484,11 @@ int DtmGlobalReserve(TransactionId xid, int nXids, TransactionId *first)
503484bool DtmGlobalDetectDeadLock (TransactionId xid , void * data , int size )
504485{
505486 int msg_size = size + sizeof (xid )* 2 ;
506- int data_size = sizeof (ShubMessageHdr ) + msg_size ;
507- char * buf = (char * )malloc (data_size );
487+ int data_size = sizeof (ShubMessageHdr ) + msg_size ;
488+ char * buf = (char * )malloc (data_size );
508489 ShubMessageHdr * msg = (ShubMessageHdr * )buf ;
509490 xid_t * body = (xid_t * )(msg + 1 );
510- int sent ;
491+ int sent ;
511492 int reslen ;
512493 xid_t results [RESULTS_SIZE ];
513494 DTMConn dtm = GetConnection ();
@@ -517,8 +498,8 @@ bool DtmGlobalDetectDeadLock(TransactionId xid, void* data, int size)
517498 msg -> size = msg_size ;
518499
519500 * body ++ = CMD_DEADLOCK ;
520- * body ++ = xid ;
521- memcpy (body , data , size );
501+ * body ++ = xid ;
502+ memcpy (body , data , size );
522503
523504 sent = 0 ;
524505 while (sent < data_size )
@@ -531,10 +512,17 @@ bool DtmGlobalDetectDeadLock(TransactionId xid, void* data, int size)
531512 }
532513 sent += new_bytes ;
533514 }
515+
534516 reslen = dtm_recv_results (dtm , RESULTS_SIZE , results );
535- if (reslen != 1 || (results [0 ] != RES_OK && results [0 ] != RES_DEADLOCK )) {
536- fprintf (stderr , "DtmGlobalDetectDeadLock: failed to check deadlocks for transaction %u\n" , xid );
537- return false;
538- }
517+ if (reslen != 1 || (results [0 ] != RES_OK && results [0 ] != RES_DEADLOCK ))
518+ {
519+ fprintf (
520+ stderr ,
521+ "DtmGlobalDetectDeadLock: failed"
522+ " to check xid=%u for deadlock\n" ,
523+ xid
524+ );
525+ return false;
526+ }
539527 return results [0 ] == RES_DEADLOCK ;
540528}
0 commit comments