diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2014-08-10 04:00:15 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2014-08-10 04:00:15 +0800 |
commit | 066bc87114c0f3e90c0858992a3fafd30101578b (patch) | |
tree | 5a82633ac8caf1fa5b4d5e297c4ed90f21a283e4 | |
parent | 7faf0c568eba2216a25854a1b0b69990103ef309 (diff) | |
download | pttbbs-066bc87114c0f3e90c0858992a3fafd30101578b.tar pttbbs-066bc87114c0f3e90c0858992a3fafd30101578b.tar.gz pttbbs-066bc87114c0f3e90c0858992a3fafd30101578b.tar.bz2 pttbbs-066bc87114c0f3e90c0858992a3fafd30101578b.tar.lz pttbbs-066bc87114c0f3e90c0858992a3fafd30101578b.tar.xz pttbbs-066bc87114c0f3e90c0858992a3fafd30101578b.tar.zst pttbbs-066bc87114c0f3e90c0858992a3fafd30101578b.zip |
Speed up by preventing flush.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@6055 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rwxr-xr-x | pttbbs/daemon/postd/postd.py | 10 | ||||
-rw-r--r-- | pttbbs/daemon/postd/rebuild.c | 10 |
2 files changed, 11 insertions, 9 deletions
diff --git a/pttbbs/daemon/postd/postd.py b/pttbbs/daemon/postd/postd.py index 2d5deffc..4e9d1fe7 100755 --- a/pttbbs/daemon/postd/postd.py +++ b/pttbbs/daemon/postd/postd.py @@ -165,29 +165,31 @@ def handle_request(socket, _): content_len = SavePost(None, False, key, header, extra) fd.write(struct.pack(CONTENT_LEN_FORMAT, content_len)) elif req.operation == REQ_IMPORT: + num = 0 g_db.batch(True) while req.operation == REQ_IMPORT: + num += 1 header = DecodeFileHeader(fd.read(pttstruct.FILEHEADER_SIZE)) extra = read_and_unpack(fd, AddRecordFormatString, AddRecord) key = read_and_unpack(fd, PostKeyFormatString, PostKey) content_len = SavePost(None, True, key, header, extra) - fd.write(struct.pack(CONTENT_LEN_FORMAT, content_len)) - fd.flush() req = read_and_unpack(fd, RequestFormatString, Request) g_db.batch(False) + fd.write(struct.pack(CONTENT_LEN_FORMAT, num)) elif req.operation == REQ_IMPORT_REMOTE: + num = 0 g_db.batch(True) while req.operation == REQ_IMPORT_REMOTE: + num += 1 header = DecodeFileHeader(fd.read(pttstruct.FILEHEADER_SIZE)) extra = read_and_unpack(fd, AddRecordFormatString, AddRecord) key = read_and_unpack(fd, PostKeyFormatString, PostKey) content_len = read_and_unpack(fd, CONTENT_LEN_FORMAT)[0] content = fd.read(content_len) content_len = SavePost(content, True, key, header, extra) - fd.write(struct.pack(CONTENT_LEN_FORMAT, content_len)) - fd.flush() req = read_and_unpack(fd, RequestFormatString, Request) g_db.batch(False) + fd.write(struct.pack(CONTENT_LEN_FORMAT, num)) elif req.operation == REQ_GET_CONTENT: key = read_and_unpack(fd, PostKeyFormatString, PostKey) content = GetPostContent(key) diff --git a/pttbbs/daemon/postd/rebuild.c b/pttbbs/daemon/postd/rebuild.c index 919e9b35..6c710c5f 100644 --- a/pttbbs/daemon/postd/rebuild.c +++ b/pttbbs/daemon/postd/rebuild.c @@ -8,7 +8,6 @@ int PostAddRecord(int s, const char *board, const fileheader_t *fhdr, const char { int success = 1; PostAddRequest req = {0}; - uint32_t len = 0; char *userid; char xuid[IDLEN + 1]; @@ -70,11 +69,9 @@ int PostAddRecord(int s, const char *board, const fileheader_t *fhdr, const char success = 0; } free(content); + if (success) + printf(" (content: %d)", content_len); } - if (success && toread(s, &len, sizeof(len)) < 0) - success = 0; - if (success) - printf(" (content: %d)", len); return !success; } @@ -124,9 +121,12 @@ void rebuild_board(int bid GCC_UNUSED, boardheader_t *bp, int is_remote) // shutdown request { + int32_t num = 0; PostAddRequest req = {0}; req.cb = sizeof(req); towrite(s, &req, sizeof(req)); + toread(s, &num, sizeof(num)); + printf(" (total added %d entries)\n", num); close(s); } |