X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fmigrate%2Fserv_migrate.c;h=39ffc73b9782f664d84d6f1afe5690d227e7814a;hb=9e7955f89c38690b915739864bae178fff0f6474;hp=41a2fdf2497d3dc323e078292367069e235eaca0;hpb=c6579e9bf76c520390532dd3866839ca13d61b70;p=citadel.git
diff --git a/citadel/modules/migrate/serv_migrate.c b/citadel/modules/migrate/serv_migrate.c
index 41a2fdf24..39ffc73b9 100644
--- a/citadel/modules/migrate/serv_migrate.c
+++ b/citadel/modules/migrate/serv_migrate.c
@@ -297,8 +297,8 @@ void migr_export_message(long msgnum) {
client_write("", 23); xml_strout(smi.meta_content_type); client_write("\n", 25);
client_write("", 10);
- serialize_message(&smr, msg);
- CtdlFreeMessage(msg);
+ CtdlSerializeMessage(&smr, msg);
+ CM_Free(msg);
/* Predict the buffer size we need. Expand the buffer if necessary. */
int encoded_len = smr.len * 15 / 10 ;
@@ -524,6 +524,7 @@ void migr_xml_chardata(void *data, const XML_Char *s, int len) {
old_len = migr_chardata_len;
new_len = old_len + len;
+
new_buffer = realloc(migr_chardata, new_len + 1);
if (new_buffer != NULL) {
memcpy(&new_buffer[old_len], s, len);
@@ -868,6 +869,7 @@ void migr_xml_end(void *data, const char *el) {
cdb_store(CDB_MSGMAIN, &import_msgnum, sizeof(long), decoded_msg, msglen);
free(decoded_msg);
decoded_msg = NULL;
+ smi.meta_msgnum = import_msgnum;
PutMetaData(&smi);
syslog(LOG_INFO, "Imported message #%ld, size=%ld, refcount=%d, content-type: %s\n",
import_msgnum, msglen, smi.meta_refcount, smi.meta_content_type);
@@ -889,12 +891,12 @@ void migr_xml_end(void *data, const char *el) {
* Import begins here
*/
void migr_do_import(void) {
- char buf[SIZ];
+ StrBuf *Buf;
XML_Parser xp;
- int linelen;
+ int Finished = 0;
unbuffer_output();
-
+ Buf = NewStrBufPlain(NULL, SIZ);
xp = XML_ParserCreate(NULL);
if (!xp) {
cprintf("%d Failed to create XML parser instance\n", ERROR+INTERNAL_ERROR);
@@ -908,22 +910,28 @@ void migr_do_import(void) {
cprintf("%d sock it to me\n", SEND_LISTING);
unbuffer_output();
- while (client_getln(buf, sizeof buf) >= 0 && strcmp(buf, "000")) {
- linelen = strlen(buf);
- strcpy(&buf[linelen++], "\n");
+ client_set_inbound_buf(SIZ * 10);
+ while (!Finished && client_read_random_blob(Buf, -1) >= 0) {
+ if ((StrLength(Buf) > 4) &&
+ !strcmp(ChrPtr(Buf) + StrLength(Buf) - 4, "000\n"))
+ {
+ Finished = 1;
+ StrBufCutAt(Buf, StrLength(Buf) - 4, NULL);
+ }
if (server_shutting_down)
break; // Should we break or return?
- if (buf[0] == '\0')
+ if (StrLength(Buf) == 0)
continue;
- XML_Parse(xp, buf, linelen, 0);
+ XML_Parse(xp, ChrPtr(Buf), StrLength(Buf), 0);
+ FlushStrBuf(Buf);
}
XML_Parse(xp, "", 0, 1);
XML_ParserFree(xp);
-
+ FreeStrBuf(&Buf);
rebuild_euid_index();
rebuild_usersbynumber();
CC->dont_term = 0;