Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitafdf647

Browse files
committed
Fix some typos and code formatting in libdtm.
1 parentd63b397 commitafdf647

File tree

2 files changed

+27
-36
lines changed

2 files changed

+27
-36
lines changed

‎contrib/pg_dtm/libdtm.c‎

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ static char* dtm_unix_sock_dir;
3333

3434
typedefunsignedxid_t;
3535

36-
// Connects to the specified DTM.
3736
staticDTMConnDtmConnect(char*host,intport)
3837
{
3938
DTMConndtm;
@@ -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.
304299
TransactionIdDtmGlobalStartTransaction(Snapshotsnapshot,TransactionId*gxmin)
305300
{
306301
inti;
@@ -337,8 +332,6 @@ TransactionId DtmGlobalStartTransaction(Snapshot snapshot, TransactionId *gxmin)
337332
returnINVALID_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.
342335
voidDtmGlobalGetSnapshot(TransactionIdxid,Snapshotsnapshot,TransactionId*gxmin)
343336
{
344337
inti;
@@ -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.
383372
XidStatusDtmGlobalSetTransStatus(TransactionIdxid,XidStatusstatus,boolwait)
384373
{
385374
intreslen;
@@ -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.
430416
XidStatusDtmGlobalGetTransStatus(TransactionIdxid,boolwait)
431417
{
432418
intreslen;
@@ -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.
470451
intDtmGlobalReserve(TransactionIdxid,intnXids,TransactionId*first)
471452
{
472453
xid_txmin,xmax;
@@ -503,11 +484,11 @@ int DtmGlobalReserve(TransactionId xid, int nXids, TransactionId *first)
503484
boolDtmGlobalDetectDeadLock(TransactionIdxid,void*data,intsize)
504485
{
505486
intmsg_size=size+sizeof(xid)*2;
506-
intdata_size=sizeof(ShubMessageHdr)+msg_size;
507-
char*buf= (char*)malloc(data_size);
487+
intdata_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-
intsent;
491+
intsent;
511492
intreslen;
512493
xid_tresults[RESULTS_SIZE];
513494
DTMConndtm=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
returnresults[0]==RES_DEADLOCK;
540528
}

‎contrib/pg_dtm/libdtm.h‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#defineINVALID_XID 0
1010

1111
/**
12-
* Sets up the host and port forDTM connection.
12+
* Sets up the host and port forarbiter connection.
1313
* The defaults are "127.0.0.1" and 5431.
1414
*/
1515
voidDtmGlobalConfig(char*host,intport,char*sock_dir);
@@ -19,21 +19,21 @@ void DtmInitSnapshot(Snapshot snapshot);
1919
/**
2020
* Starts a new global transaction. Returns the
2121
* transaction id, fills the 'snapshot' and 'gxmin' on success. 'gxmin' is the
22-
* smallest xmin among all snapshots known toDTM. Returns INVALID_XID
22+
* smallest xmin among all snapshots known toarbiter. Returns INVALID_XID
2323
* otherwise.
2424
*/
2525
TransactionIdDtmGlobalStartTransaction(Snapshotsnapshot,TransactionId*gxmin);
2626

2727
/**
28-
* Asks theDTM for a fresh snapshot. Fills the 'snapshot' and 'gxmin' on
29-
* success. 'gxmin' is the smallest xmin among all snapshots known toDTM.
28+
* Asks thearbiter for a fresh snapshot. Fills the 'snapshot' and 'gxmin' on
29+
* success. 'gxmin' is the smallest xmin among all snapshots known toarbiter.
3030
*/
3131
voidDtmGlobalGetSnapshot(TransactionIdxid,Snapshotsnapshot,TransactionId*gxmin);
3232

3333
/**
3434
* Commits transaction only once all participants have called this function,
3535
* does not change CLOG otherwise. Set 'wait' to 'true' if you want this call
36-
* to return only after the transaction is considered finished by theDTM.
36+
* to return only after the transaction is considered finished by thearbiter.
3737
* Returns the status on success, or -1 otherwise.
3838
*/
3939
XidStatusDtmGlobalSetTransStatus(TransactionIdxid,XidStatusstatus,boolwait);
@@ -55,9 +55,12 @@ XidStatus DtmGlobalGetTransStatus(TransactionId xid, bool wait);
5555
intDtmGlobalReserve(TransactionIdxid,intnXids,TransactionId*first);
5656

5757
/**
58-
* Detect global deadlock. This funcions send serialized local resource graph to arbiter which appends them to global graph.
59-
* Once loop is detected in global resoruce graph, arbiter returns true. Otherwise false is returned.
60-
* Abiter should replace local part of resource graph if new graph is recevied from this cluster node (not backend).
58+
* Detect global deadlock. This function sends serialized local resource graph
59+
* to the arbiter which appends them to the global graph. Once a loop is
60+
* detected in global resource graph, the arbiter returns true. Otherwise false
61+
* is returned. Arbiter should replace the corresponding part of the global
62+
* resource graph if a new local graph is received from this cluster node (not
63+
* backend).
6164
*/
6265
boolDtmGlobalDetectDeadLock(TransactionIdxid,void*graph,intsize);
6366

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp