@@ -33,7 +33,6 @@ static char* dtm_unix_sock_dir;
33
33
34
34
typedef unsigned xid_t ;
35
35
36
- // Connects to the specified DTM.
37
36
static DTMConn DtmConnect (char * host , int port )
38
37
{
39
38
DTMConn dtm ;
@@ -297,10 +296,6 @@ void DtmInitSnapshot(Snapshot snapshot)
297
296
#endif
298
297
}
299
298
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.
304
299
TransactionId DtmGlobalStartTransaction (Snapshot snapshot , TransactionId * gxmin )
305
300
{
306
301
int i ;
@@ -337,8 +332,6 @@ TransactionId DtmGlobalStartTransaction(Snapshot snapshot, TransactionId *gxmin)
337
332
return INVALID_XID ;
338
333
}
339
334
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.
342
335
void DtmGlobalGetSnapshot (TransactionId xid , Snapshot snapshot , TransactionId * gxmin )
343
336
{
344
337
int i ;
@@ -376,10 +369,6 @@ void DtmGlobalGetSnapshot(TransactionId xid, Snapshot snapshot, TransactionId *g
376
369
);
377
370
}
378
371
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.
383
372
XidStatus DtmGlobalSetTransStatus (TransactionId xid , XidStatus status , bool wait )
384
373
{
385
374
int reslen ;
@@ -424,9 +413,6 @@ XidStatus DtmGlobalSetTransStatus(TransactionId xid, XidStatus status, bool wait
424
413
return -1 ;
425
414
}
426
415
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.
430
416
XidStatus DtmGlobalGetTransStatus (TransactionId xid , bool wait )
431
417
{
432
418
int reslen ;
@@ -462,11 +448,6 @@ XidStatus DtmGlobalGetTransStatus(TransactionId xid, bool wait)
462
448
return -1 ;
463
449
}
464
450
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.
470
451
int DtmGlobalReserve (TransactionId xid , int nXids , TransactionId * first )
471
452
{
472
453
xid_t xmin , xmax ;
@@ -503,11 +484,11 @@ int DtmGlobalReserve(TransactionId xid, int nXids, TransactionId *first)
503
484
bool DtmGlobalDetectDeadLock (TransactionId xid , void * data , int size )
504
485
{
505
486
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 );
508
489
ShubMessageHdr * msg = (ShubMessageHdr * )buf ;
509
490
xid_t * body = (xid_t * )(msg + 1 );
510
- int sent ;
491
+ int sent ;
511
492
int reslen ;
512
493
xid_t results [RESULTS_SIZE ];
513
494
DTMConn dtm = GetConnection ();
@@ -517,8 +498,8 @@ bool DtmGlobalDetectDeadLock(TransactionId xid, void* data, int size)
517
498
msg -> size = msg_size ;
518
499
519
500
* body ++ = CMD_DEADLOCK ;
520
- * body ++ = xid ;
521
- memcpy (body , data , size );
501
+ * body ++ = xid ;
502
+ memcpy (body , data , size );
522
503
523
504
sent = 0 ;
524
505
while (sent < data_size )
@@ -531,10 +512,17 @@ bool DtmGlobalDetectDeadLock(TransactionId xid, void* data, int size)
531
512
}
532
513
sent += new_bytes ;
533
514
}
515
+
534
516
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
+ }
539
527
return results [0 ] == RES_DEADLOCK ;
540
528
}
0 commit comments