Changeset: eb4eb664a3ee for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=eb4eb664a3ee
Modified Files:
MonetDB5/src/modules/mal/replication.mx
Branch: default
Log Message:
uncrustify
diffs (truncated from 1102 to 300 lines):
diff -r fa6199240d8a -r eb4eb664a3ee MonetDB5/src/modules/mal/replication.mx
--- a/MonetDB5/src/modules/mal/replication.mx Fri Jul 16 14:50:13 2010 +0200
+++ b/MonetDB5/src/modules/mal/replication.mx Fri Jul 16 15:12:07 2010 +0200
@@ -427,8 +427,9 @@
static int acceptLogs = 0;
static void
-SLAVEinitLog(){
- if ( slavecommit == NULL){
+SLAVEinitLog()
+{
+ if (slavecommit == NULL) {
@:createBAT(slavetid,TYPE_oid)@
@:createBAT(slavecommit,TYPE_timestamp)@
@:createBAT(slavevalid,TYPE_timestamp)@
@@ -436,109 +437,109 @@
}
}
-static int
-MASTERfindLogFile(char logFile[PATHLENGTH], oid transactionid){
+static int
+MASTERfindLogFile(char logFile[PATHLENGTH], oid transactionid)
+{
oid btag, etag;
DIR *dirp;
struct dirent *dent;
#ifdef _DEBUG_REPLICATION_
- stream_printf(GDKout,"#find the log file containing %d\n",
transactionid);
+ stream_printf(GDKout, "#find the log file containing %d\n",
transactionid);
#endif
if (repFile)
stream_close(repFile);
repFile = NULL;
- dirp= opendir(MASTER);
+ dirp = opendir(MASTER);
if (dirp == NULL)
- return -1 ;
- while ((dent = readdir(dirp)) != NULL)
- if ( sscanf(dent->d_name,"log" OIDFMT"-" OIDFMT,&btag,&etag) ==
2 && btag <= transactionid && transactionid<etag ){
- snprintf(logFile, PATHLENGTH,"%s%s",MASTER,
dent->d_name);
+ return -1;
+ while ((dent = readdir(dirp)) != NULL)
+ if (sscanf(dent->d_name, "log" OIDFMT "-" OIDFMT, &btag, &etag)
== 2 && btag <= transactionid && transactionid < etag) {
+ snprintf(logFile, PATHLENGTH, "%s%s", MASTER,
dent->d_name);
slash_2_dir_sep(logFile);
- return (int) etag;
+ return (int)etag;
}
return -1;
}
/* The replication log file contains a number of log functions.
- * When the limit is reached, we switch to a new file
-*/
+ * When the limit is reached, we switch to a new file */
static int
MASTERincrement()
{
char buf[PATHLENGTH];
- endTag++; /* assign a new transaction identifier */
+ endTag++; /* assign a new transaction identifier */
snprintf(buf, PATHLENGTH, MASTER REPLICA, startTag, endTag);
slash_2_dir_sep(buf);
- if (strcmp(logFile,buf) )
- rename(logFile,buf);
- strcpy(logFile,buf);
+ if (strcmp(logFile, buf))
+ rename(logFile, buf);
+ strcpy(logFile, buf);
/* once in a while we take a new log file */
- if ( endTag - startTag >= REPLICABLOCK){
- if ( repFile)
+ if (endTag - startTag >= REPLICABLOCK) {
+ if (repFile)
stream_close(repFile);
repFile = NULL;
}
- if ( repFile == NULL)
+ if (repFile == NULL)
repFile = open_wastream(buf);
return repFile == NULL;
}
str
-MASTERprelude(int *ret){
+MASTERprelude(int *ret)
+{
int master;
oid tag, etag;
DIR *dirp;
struct dirent *dent;
- (void) ret;
- MT_lock_init(&repLck, "replication"); /* we always need this */
+ (void)ret;
+ MT_lock_init(&repLck, "replication"); /* we always need this */
master = GDKgetenv_istrue("replication_master") &&
GDKgetenv("replication_slave") == NULL;
#ifdef _DEBUG_REPLICATION_
- stream_printf(GDKout,"#Initialize the master role?%s\n",
master?"yes":"no");
+ stream_printf(GDKout, "#Initialize the master role?%s\n", master ?
"yes" : "no");
#endif
mal_set_lock(repLck, "replication");
- if( !master ){
+ if (!master) {
/* drop all remaining log files if master mode is switched off
*/
GDKremovedir(MASTER);
mal_unset_lock(repLck, "replication");
return MAL_SUCCEED;
}
mkdir(MASTER, 0755); /* ensure existance of the replica pool */
- stream_printf(GDKout,"# Replication mode enabled\n");
-
+ stream_printf(GDKout, "# Replication mode enabled\n");
+
/* find the bounds for the last replication log file */
/* assume directory is sorted */
- dirp= opendir(MASTER);
+ dirp = opendir(MASTER);
if (dirp == NULL) {
mal_unset_lock(repLck, "replication");
return MAL_SUCCEED;
}
cutoffTag = INT_MAX;
while ((dent = readdir(dirp)) != NULL) {
- if ( sscanf(dent->d_name,"log"OIDFMT"-"OIDFMT,&tag,&etag) == 2
){
- if ( tag < cutoffTag)
+ if (sscanf(dent->d_name, "log" OIDFMT "-" OIDFMT, &tag, &etag)
== 2) {
+ if (tag < cutoffTag)
cutoffTag = tag;
- if ( tag >= startTag){
- startTag= tag;
- endTag= etag;
- strcpy(logFile,dent->d_name);
+ if (tag >= startTag) {
+ startTag = tag;
+ endTag = etag;
+ strcpy(logFile, dent->d_name);
}
}
- }
+ }
if (cutoffTag == INT_MAX)
cutoffTag = 0;
#ifdef _DEBUG_REPLICATION_
- stream_printf(GDKout,"#last log file log%05d-%05d\n", startTag,endTag);
+ stream_printf(GDKout, "#last log file log%05d-%05d\n", startTag,
endTag);
#endif
startTag = endTag;
sendLogs = TRUE;
mal_unset_lock(repLck, "replication");
return MAL_SUCCEED;
}
-
str
MASTERgetURI(str *ret)
@@ -554,8 +555,9 @@
}
str
-MASTERgetCutOffTag(int *ret){
- *ret = (int) cutoffTag;
+MASTERgetCutOffTag(int *ret)
+{
+ *ret = (int)cutoffTag;
return MAL_SUCCEED;
}
@@ -565,7 +567,8 @@
return startTag > 0;
}
-static int MASTERgetBuffer(oid tag)
+static int
+MASTERgetBuffer(oid tag)
{
int i;
@@ -578,8 +581,7 @@
if (i == 0) {
master = GDKzalloc(sizeof(struct MASTERRECORD) * (mlimit + 32));
mlimit = 32;
- } else
- if (i == mlimit) {
+ } else if (i == mlimit) {
master = GDKrealloc(master, sizeof(struct MASTERRECORD) *
(mlimit + 32));
mlimit += 32;
}
@@ -592,12 +594,14 @@
master[i].tag = tag;
return i;
}
-...@-
+
+/*
For the time being, we assume that all chunks are kept in the
master directory. A better scheme is to find the last chunk
by reading the directory itself.
-...@c
-str MASTERopen(oid *ret)
+*/
+str
+MASTERopen(oid *ret)
{
int i, l, len;
@@ -609,12 +613,12 @@
len = master[i].limit - master[i].top - 1;
master[i].fcn = fcnTag;
while ((l = snprintf(master[i].buf + master[i].top, len,
- "function
slave.tag_%d{unsafe}(tag:oid,stamp:timestamp);\n"
- "barrier doit:= slave.open(tag);\n"
- "sql.transaction();\n",
+ "function
slave.tag_%d{unsafe}(tag:oid,stamp:timestamp);\n"
+ "barrier doit:= slave.open(tag);\n"
+ "sql.transaction();\n",
fcnTag)) == len) {
master[i].buf = (char*)GDKrealloc(master[i].buf,
master[i].limit + 1024);
- if (master[i].buf == NULL){
+ if (master[i].buf == NULL) {
mal_unset_lock(repLck, "replication");
throw(MAL, "replication.open", MAL_MALLOC_FAIL);
}
@@ -629,11 +633,10 @@
return MAL_SUCCEED;
}
-/*
- * Upon closure of the transaction, we assign the transaction identifier
- * and reflect it in the log file name as well.
-*/
-str MASTERclose(int *ret, oid *tag)
+/* Upon closure of the transaction, we assign the transaction identifier
+ * and reflect it in the log file name as well. */
+str
+MASTERclose(int *ret, oid *tag)
{
timestamp stamp = *timestamp_nil;
str val = NULL;
@@ -645,23 +648,22 @@
mal_set_lock(repLck, "replication");
MTIMEepoch(&stamp);
ATOMformat(TYPE_timestamp, (ptr) & stamp, &val);
- snprintf(buf,BUFSIZ,"tag_"OIDFMT, *tag);
+ snprintf(buf, BUFSIZ, "tag_" OIDFMT, *tag);
/* the function name is returned by the slave to built
a flow dependency. Otherwise the function could be
- destroyed while execution it.
- */
+ destroyed while execution it. */
len = master[i].limit - master[i].top - 1;
while ((l = snprintf(master[i].buf + master[i].top, len,
- "sql.commit();\n"
- "slave.close(tag,stamp);\n"
- "exit doit;\n"
- "end %s;\n"
- "slave.%s("OIDFMT":oid,\"%s\":timestamp);\n"
- "slave.drop(\"%s\");\n",
- buf,buf, endTag, val,buf)) == len) {
+ "sql.commit();\n"
+ "slave.close(tag,stamp);\n"
+ "exit doit;\n"
+ "end %s;\n"
+ "slave.%s(" OIDFMT ":oid,\"%s\":timestamp);\n"
+
"slave.drop(\"%s\");\n",
+ buf, buf, endTag, val, buf)) == len) {
master[i].buf = (char*)GDKrealloc(master[i].buf,
master[i].limit + 1024);
- if (master[i].buf == NULL){
+ if (master[i].buf == NULL) {
mal_unset_lock(repLck, "replication");
throw(MAL, "replication.close", MAL_MALLOC_FAIL);
}
@@ -671,7 +673,7 @@
GDKfree(val);
MASTERincrement();
- if (repFile == NULL ){
+ if (repFile == NULL) {
mal_unset_lock(repLck, "replication");
throw(MAL, "master.close", RUNTIME_FILE_NOT_FOUND);
}
@@ -681,7 +683,7 @@
master[i].top = 0;
master[i].tag = 0;
mal_unset_lock(repLck, "replication");
- if (stream_errnr(repFile))
+ if (stream_errnr(repFile))
throw(MAL, "replication.close", RUNTIME_STREAM_FAILED);
return MAL_SUCCEED;
}
@@ -698,37 +700,35 @@
i = MASTERgetBuffer(tag);
bi = bat_iterator(b);
- BATaccessBegin(b,USE_HEAD|USE_TAIL,MMAP_SEQUENTIAL);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list