summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-11-23 15:33:51 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-11-23 15:33:51 +0000
commit6125b6bc5204a618e6fc8976600332a423bd0fc0 (patch)
tree360d8a40b968249f79e604e05e7545a6aa0f47c9 /src/common
parentda0983d53b36267e16212ba58453c442eaaf1f18 (diff)
downloadhercules-6125b6bc5204a618e6fc8976600332a423bd0fc0.tar.gz
hercules-6125b6bc5204a618e6fc8976600332a423bd0fc0.tar.bz2
hercules-6125b6bc5204a618e6fc8976600332a423bd0fc0.tar.xz
hercules-6125b6bc5204a618e6fc8976600332a423bd0fc0.zip
- Made WFIFOHEAD() check for available buffer size remaining on the connection, and when there's not enough space, it will increase it.
- Added define TURBO to the Makefile. It enables MouseJstr's socket access optimization which should speed up the code when accessing the write/read buffers repeatedly within a function. - Fixed the functions where the RFIFOHEAD/WFIFOHEAD functions were used incorrectly (prevents TURBO enabled compilations from finishing) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9297 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r--src/common/socket.c3
-rw-r--r--src/common/socket.h3
2 files changed, 4 insertions, 2 deletions
diff --git a/src/common/socket.c b/src/common/socket.c
index 2e52b079f..f7cb5d33b 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -701,7 +701,8 @@ int WFIFOSET(int fd,int len)
unsigned char *sin_addr = (unsigned char *)&s->client_addr.sin_addr;
ShowFatalError("socket: Buffer Overflow. Connection %d (%d.%d.%d.%d) has written %d byteson a %d/%d bytes buffer.\n", fd,
sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3], len, s->wdata_size, s->max_wdata);
- ShowDebug("Likely command that caused it: 0x%x\n", WFIFOW(fd,0));
+ ShowDebug("Likely command that caused it: 0x%x\n",
+ (*(unsigned short*)(s->wdata+s->wdata_size)));
// no other chance, make a better fifo model
exit(1);
}
diff --git a/src/common/socket.h b/src/common/socket.h
index 2774b9c7f..02badae3f 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -58,7 +58,8 @@ extern time_t stall_time;
#define WFIFOHEAD(fd, x) char *wbPtr = session[fd]->wdata+session[fd]->wdata_size;
#define WFIFOP(fd,pos) (&wbPtr[pos])
#else
-#define WFIFOHEAD(fd, x) ;
+#define WFIFOHEAD(fd, size) { if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) realloc_writefifo(fd, size); }
+
#define WFIFOP(fd,pos) (session[fd]->wdata+session[fd]->wdata_size+(pos))
#endif
#define WFIFOB(fd,pos) (*(unsigned char*)WFIFOP(fd,pos))