D 2010-10-15T21:08:35 J +comment \n\nwolfgang\sadded\son\s2010-10-15\s21:08:35:\nI've\sused\syour\spatch\sand\safter\sadding\s\r\n
\r\n\s\s\s\shttp_exchange(&send,\s&recv,\scloneFlag==0\s||\snCycle>0);\r\n\s\s\s\sblob_reset(&send);\r\n
\r\nto\sthe\sclient\scode\sand\smaking\sthe\scmd\sarray\sin\sthe\shook\sfunction\slarger,\sit\sworks.\s\r\n\r\nBut\ssome\sremarks:\r\n\s\s*\s\sThe\sserver\sprocess\swaits\suntil\sthe\send\sof\sthe\shook.\sI\sdon't\sthink,\sthat\sis\sis\sreally\sa\sgood\sthing\r\n\s\s*\s\ssimply\sappending\soutputs\sto\sa\sfile\smay\sbecome\stricky,\sif\smultiple\sclient\srequest\scome\sin\sat\sthe\ssame\stime.\sThe\sparallel\srunning\shook\sjobs\swill\sappend\stheir\sdata\sat\sthe\ssame\stime\sand\swill\smess\sup\sthe\slogs\r\n\r\nThe\sidea\sof\ssending\sa\sspecial\s'do-it'-line\sfrom\sthe\sclient\sis\snice.\sThe\swhole\sthing\smight\sbe\sextended\s-\si\sknow,\syour\spatch\sis\snot\sfinished\s:-)\s-\swith:\r\n\s\s*\s\sthe\shook\scommand\sshould\sbe\sconfigured\sby\sa\ssetting\s(gui\sand/or\scommand\sline\ssetting)\r\n\s\s*\s\sredirects\sof\sstdin/stderr\sshould\sbe\spart\sof\sthe\scommand\sconfiguration\r\n\s\s*\s\sthe\sclient\scould\suse\sa\sspecial\ssettings\sstring,\swhich\swould\sbe\sappended\sto\sthe\s'do-it'-line.\sThis\ssetting\scould\sbe\sread\sby\sthe\sserver\sand\sadded\sto\sthe\scommand\sline\sof\sthe\sserver.\sThis\sway,\sthe\susers\sof\ssuch\shooks\scan\sconfigure\sthe\smessage\spassing\sduring\sthe\ssync.\sGiven\syour\spatch,\sthe\sclient\smight\ssend\s#FAT\sbuild\sand\sthe\sserver\swould\scall\stargetcmd\sbuild\r\n\s\s*\s\sif\sboth\ssides\sof\sthe\sline\suse\sa\ssetting\sfor\sthe\s'do-it'\sstring\s(FAT\sin\syour\spatch),\sit\swould\sbe\sfully\sconfigurable,\sif\sthe\sclients\swants\sto\ssend\sa\s'do-it'\sline\sand/or\sthe\sserver\srecognizes\sthese\srequests.\r\n\r\nbest\sregards
Wolfgang\r\n\r\nThe\sresults\sof\smy\stests:\r\n
\r\nIndex:\ssrc/xfer.c\r\n===================================================================\r\n---\ssrc/xfer.c\r\n+++\ssrc/xfer.c\r\n@@\s-40,10\s+40,26\s@@\r\n\s\s\sint\snDeltaRcvd;\s\s\s\s\s/*\sNumber\sof\sdeltas\sreceived\s*/\r\n\s\s\sint\snDanglingFile;\s\s/*\sNumber\sof\sdangling\sdeltas\sreceived\s*/\r\n\s\s\sint\smxSend;\s\s\s\s\s\s\s\s\s/*\sStop\ssending\s"file"\swith\spOut\sreaches\sthis\ssize\s*/\r\n\s};\r\n\r\n+/*\r\n+**\sLet\sa\sserver-side\sexternal\sagent\sknow\sthat\sa\spush\shas\scompleted.\s/fatman\r\n+*/\r\n+void\spost_push_hook()\s{\r\n+\s\s/*\r\n+\s\s**\sTO\sDO:\sget\sthe\sstring\scmd\sfrom\sa\sconfig\sfile?\sOr\sthe\sdatabase\slocal\r\n+\s\s**\ssettings,\sas\ssomeone\ssuggested?\sDitto\soutput\sand\serror\slogs.\s/fatman\r\n+\s\s*/\r\n+\s\schar\scmd[1024]\s=\s"targetcmd";\r\n+\s\sstrcat(cmd,\s"\s>target.out\s2>target.err");\r\n+\s\sconst\schar\s*ptr\s=\scmd;\r\n+\s\sint\src\s=\ssystem(ptr);\r\n+\s\sif\s(rc\s!=\s0)\s{\r\n+\s\s\s\sfossil_print("The\spost-push-hook\scommand\s\\"%s\\"\sfailed.",\sptr);\r\n+\s\s}\r\n+}\r\n\r\n\s/*\r\n\s**\sThe\sinput\sblob\scontains\sa\sUUID.\s\sConvert\sit\sinto\sa\srecord\sID.\r\n\s**\sCreate\sa\sphantom\srecord\sif\sno\sprior\srecord\sexists\sand\r\n\s**\sphantomize\sis\strue.\r\n@@\s-617,11\s+633,17\s@@\r\n\s\s\s);\r\n\s\s\szNow\s=\sdb_text(0,\s"SELECT\sstrftime('%%Y-%%m-%%dT%%H:%%M:%%S',\s'now')");\r\n\s\s\s@\s#\stimestamp\s%s(zNow)\r\n\s\s\smanifest_crosslink_begin();\r\n\s\s\swhile(\sblob_line(xfer.pIn,\s&xfer.line)\s){\r\n-\s\s\s\sif(\sblob_buffer(&xfer.line)[0]=='#'\s)\scontinue;\r\n+\s\s\s\sif(\sblob_buffer(&xfer.line)[0]=='#'\s){\r\n+\s\s\s\s\s\sif\s(\s0\s==\smemcmp(blob_buffer(&xfer.line),\s"#FAT",\s4)\s){\r\n+\s\s\s\s\s\s\s\sfprintf(stderr,"HOOK\\n");\r\n+\s\s\s\s\s\s\spost_push_hook();\r\n+\s\s\s\s\s\s}\r\n+\s\s\s\s\s\scontinue;\r\n+\s\s\s\s}\r\n\s\s\s\s\sxfer.nToken\s=\sblob_tokenize(&xfer.line,\sxfer.aToken,\scount(xfer.aToken));\r\n\r\n\s\s\s\s\s/*\s\s\sfile\sUUID\sSIZE\s\\n\sCONTENT\r\n\s\s\s\s\s**\s\s\sfile\sUUID\sDELTASRC\sSIZE\s\\n\sCONTENT\r\n\s\s\s\s\s**\r\n@@\s-1330,14\s+1352,20\s@@\r\n\s\s\s\s\s}\r\n\r\n\s\s\s\s\s/*\sIf\sthis\sis\sa\sclone,\sthe\sgo\sat\sleast\stwo\srounds\s*/\r\n\s\s\s\s\sif(\scloneFlag\s&&\snCycle==1\s)\sgo\s=\s1;\r\n\s\s\s};\r\n+\s\sif\s(pushFlag\s&&\snFileSend\s>\s0)\s{\r\n+\s\s\s\sblob_appendf(&send,\s"#FAT\\n");\r\n+\s\s\s\shttp_exchange(&send,\s&recv,\scloneFlag==0\s||\snCycle>0);\r\n+\s\s\s\sblob_reset(&send);\r\n+\s\s\s\snCardSent++;\r\n+\s\s}\r\n\s\s\stransport_stats(&nSent,\s&nRcvd,\s1);\r\n\s\s\sfossil_print("Total\snetwork\straffic:\s%d\sbytes\ssent,\s%d\sbytes\sreceived\\n",\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\snSent,\snRcvd);\r\n\s\s\stransport_close();\r\n\s\s\stransport_global_shutdown();\r\n\s\s\sdb_multi_exec("DROP\sTABLE\sonremote");\r\n\s\s\smanifest_crosslink_end();\r\n\s\s\sdb_end_transaction(0);\r\n\s}\r\n
J resolution Open K 77de516a1f2bfc1bd996a8520d0ce59b1b324e77 U wolfgang Z b52cffce05bdac9291fb0219b7492c83