+
+ /* Tell it we want to upload. */
+ sock_puts(&sock, "NUOP");
+ if (sock_getln(&sock, buf, sizeof buf) < 0) {
+ goto bail;
+ }
+ if (buf[0] != '2') {
+ CtdlAideMessage(buf, "NUOP error");
+ syslog(LOG_ERR, "netpoll: NUOP error talking to <%s> : %s", ChrPtr(node), buf);
+ goto bail;
+ }
+
+ fseek(netoutfp, 0, SEEK_END);
+ long total_to_send = ftell(netoutfp);
+ rewind(netoutfp);
+
+ syslog(LOG_DEBUG, "netpoll: I want to send %ld bytes to %s", total_to_send, ChrPtr(node));
+ long bytes_sent = 0;
+ while (bytes_sent < total_to_send) {
+ if (server_shutting_down) {
+ goto bail;
+ }
+
+ this_block = total_to_send - bytes_sent;
+ if (this_block > sizeof(buf)) {
+ this_block = sizeof(buf);
+ }
+
+ snprintf(buf, sizeof buf, "WRIT %d", this_block);
+ sock_puts(&sock, buf);
+ if (sock_getln(&sock, buf, sizeof buf) < 0) {
+ goto bail;
+ }
+ if (buf[0] != '7') {
+ goto bail;
+ }
+ this_block = atol(&buf[4]);
+ fread(buf, this_block, 1, netoutfp);
+ if (sock_write(&sock, buf, this_block) != this_block) {
+ goto bail;
+ }
+ bytes_sent += this_block;
+ syslog(LOG_DEBUG, "netpoll: sent %ld of %ld bytes to %s", bytes_sent, total_to_send, ChrPtr(node));
+ }
+
+ /* Tell them we're done. */
+ sock_puts(&sock, "UCLS 1"); // UCLS 1 causes it to close *and delete* on the other node
+ if (sock_getln(&sock, buf, sizeof buf) < 0) {
+ goto bail;
+ }
+ if (buf[0] == '2') {
+ unlink(ChrPtr(SpoolFileName));
+ }