From: Art Cancro Date: Tue, 18 May 2010 19:16:52 +0000 (+0000) Subject: * When a network node is uploading a spool file, receive it in ./network/spooltmp... X-Git-Tag: v7.86~207 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=d618782c3acea2b76ad78b2744093bf9b99ca6ab * When a network node is uploading a spool file, receive it in ./network/spooltmp and then move it to ./network/spoolin only when the upload is closed. (This is the first of perhaps five changes which need to be made.) --- diff --git a/citadel/file_ops.c b/citadel/file_ops.c index 0a790832a..0438b244e 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -569,6 +569,7 @@ void cmd_ucls(char *cmd) { FILE *fp; char upload_notice[512]; + static int seq = 0; if (CC->upload_fp == NULL) { cprintf("%d You don't have an upload file open.\n", ERROR + RESOURCE_NOT_OPEN); @@ -582,7 +583,27 @@ void cmd_ucls(char *cmd) CC->upload_type = UPL_FILE; cprintf("%d Upload completed.\n", CIT_OK); - /* FIXME ... here we need to trigger a network run */ + if (CC->upload_type == UPL_NET) { + char final_filename[PATH_MAX]; + snprintf(final_filename, sizeof final_filename, + "%s/%s.%04lx.%04x", + ctdl_netin_dir, + CC->net_node, + (long)getpid(), + ++seq + ); + + if (link(CC->upl_path, final_filename) == 0) { + unlink(CC->upl_path); + } + else { + CtdlLogPrintf(CTDL_ALERT, "Cannot link %d to %d: %s\n", + CC->upl_path, final_filename, strerror(errno) + ); + } + + /* FIXME ... here we need to trigger a network run */ + } return; } diff --git a/citadel/modules/network/serv_network.c b/citadel/modules/network/serv_network.c index fa5050660..a8c16a7a4 100644 --- a/citadel/modules/network/serv_network.c +++ b/citadel/modules/network/serv_network.c @@ -1974,17 +1974,18 @@ void transmit_spool(int *sock, char *remote_nodename) ABORTUPL: close(fd); - /** Last chance for shutdown exit */ + + /* Last chance for shutdown exit */ if(CtdlThreadCheckStop()) return; if (sock_puts(sock, "UCLS 1") < 0) return; - /** + + /* * From here on we must complete or messages will get lost */ if (sock_getln(sock, buf, sizeof buf) < 0) return; - CtdlLogPrintf(CTDL_NOTICE, "Sent %ld octets to <%s>\n", - bytes_written, remote_nodename); + CtdlLogPrintf(CTDL_NOTICE, "Sent %ld octets to <%s>\n", bytes_written, remote_nodename); CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf); if (buf[0] == '2') { CtdlLogPrintf(CTDL_DEBUG, "Removing <%s>\n", sfname);