diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-11 20:55:59 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-12-11 20:55:59 +0000 |
commit | c5b5dd77cead4f65fa222551a184e1401904c25d (patch) | |
tree | 4f40f32b8fc826b1373c8c9ef5d1cd32630a3f36 | |
parent | 80c3f6c4bdaeb184ff4bf66f0d465d081a1d1263 (diff) |
Finally got read buffering working properly
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5939 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/helperfuncs.cpp | 4 | ||||
-rw-r--r-- | src/modules/extra/m_ziplink.cpp | 20 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 4475c169a..05f2d79c3 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -33,10 +33,10 @@ static time_t LAST = 0; void InspIRCd::Log(int level, const char* text, ...) { va_list argsPtr; - char textbuffer[MAXBUF]; + char textbuffer[65536]; va_start(argsPtr, text); - vsnprintf(textbuffer, MAXBUF, text, argsPtr); + vsnprintf(textbuffer, 65536, text, argsPtr); va_end(argsPtr); this->Log(level, std::string(textbuffer)); diff --git a/src/modules/extra/m_ziplink.cpp b/src/modules/extra/m_ziplink.cpp index 74f767a9d..63c0862cd 100644 --- a/src/modules/extra/m_ziplink.cpp +++ b/src/modules/extra/m_ziplink.cpp @@ -263,7 +263,6 @@ class ModuleZLib : public Module return 1; unsigned char compr[CHUNK + 1]; - unsigned int total_decomp = 0; readresult = read(fd, compr, CHUNK); @@ -272,13 +271,15 @@ class ModuleZLib : public Module session->inbuf->AddData(compr, readresult); int size = 0; + std::string str_out; while ((size = session->inbuf->GetFrame(compr, CHUNK)) != 0) { + unsigned char localbuf[count + 1]; ServerInstance->Log(DEBUG,"Got size %d", size); session->d_stream.next_in = (Bytef*)compr; session->d_stream.avail_in = 0; - session->d_stream.next_out = (Bytef*)(buffer + total_decomp); + session->d_stream.next_out = (Bytef*)localbuf; if (inflateInit(&session->d_stream) != Z_OK) return -EBADF; @@ -290,17 +291,24 @@ class ModuleZLib : public Module } inflateEnd(&session->d_stream); + + ServerInstance->Log(DEBUG,"Decompressed size: %d", session->d_stream.total_out); + + localbuf[session->d_stream.total_out] = 0; + str_out.append((const char*)localbuf); + + ServerInstance->Log(DEBUG,"str_out size: %d", str_out.length()); total_in_compressed += readresult; readresult = session->d_stream.total_out; total_in_uncompressed += session->d_stream.total_out; - - total_decomp += session->d_stream.total_out; } - buffer[total_decomp] = 0; + memcpy(buffer, str_out.data(), str_out.length() > count ? count : str_out.length()); + + ServerInstance->Log(DEBUG,"Complete buffer size=%d: '%s'\r\n\r\n", str_out.length(), buffer); - ServerInstance->Log(DEBUG,"Complete buffer: '%s' size=%d", buffer, total_decomp); + readresult = str_out.length(); } return (readresult > 0); } |