a-kr / shellinabox

Automatically exported from code.google.com/p/shellinabox
Other
0 stars 0 forks source link

Terminal doesn't provide login prompt ( refill the outgoing buffer whenever it runs low.) #223

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Its quite hard to reproduce! 
2.Let it run for few days. Suddenly CPU usage reaches around 98-99%
3.At this time,siab doesn't show login prompt.The process continues running.

What is the expected output? What do you see instead?
It should display login prompt

What version of the product are you using? On what operating system?
2.14 - Fedora 14

Please provide any additional information below.
gdb trace#
(gdb) bt
#0  0x00e85d9e in vfprintf () from /lib/libc.so.6
#1  0x00e88ed2 in buffered_vfprintf () from /lib/libc.so.6
#2  0x00e84653 in vfprintf () from /lib/libc.so.6
#3  0x00e8e6cf in fprintf () from /lib/libc.so.6
#4  0x08054adf in httpConsumePayload (http=0x90b5168, buf=0x805d7ca "", len=0) 
at libhttp/httpconnection.c:1245
#5  0x08057bc4 in httpHandleConnection (connection=<value optimized out>, 
http_=0x90b5168, events=0xbfc8731e, revents=4) at libhttp/httpconnection.c:1669
#6  0x08059244 in serverLoop (server=0x9065e08) at libhttp/server.c:589
#7  0x0804d142 in main (argc=Cannot access memory at address 0xffffffec
) at shellinabox/shellinaboxd.c:1334

(gdb) f 4
#4  0x08054adf in httpConsumePayload (http=0x90b5168, buf=0x805d7ca "", len=0) 
at libhttp/httpconnection.c:1245
1245    libhttp/httpconnection.c: No such file or directory.
    in libhttp/httpconnection.c
(gdb) p buf
$1 = 0x805d7ca ""
(gdb) p http
$3 = {server = 0x9065e08, connection = 0x90b56fc, fd = 7, port = 4200, closed = 
1, isSuspended = 0, is
PartialReply = 1, done = 0, state = COMMAND, 
  peerName = 0x9082660 "fedori", peerPort = 60234, url = 0x0, method = 0x0, path = 0x0, matchedPath = 0x0, pathInfo = 0x0, query = 0x0, version = 0x0, header = {
    destructor = 0x8053a60 <httpDestroyHeaders>, arg = 0x0, entries = 0x0, mapSize = 0, numEntries = 0}, headerLength = 0, key = 0x90b5210 "", partial = 0x0, 
  partialLength = 0, msg = 0x0, msgLength = 0, msgOffset = 0, totalWritten = 0, expecting = 0, websocketType = 4096, callback = 0, websocketHandler = 0, arg = 0x0, 
  private = 0x0, code = 200, ssl = 0x0, sslHndl = 0x0, lastError = 0}
(gdb) p *http->connection
$4 = {deleted = 0, timeout = 1361821675, handleConnection = 0x8056118 
<httpHandleConnection>, destroyConnection = 0x8054791 <deleteHttpConnection>, 
arg = 0x90b5168}
(gdb) p *http->server
$5 = {port = 4200, looping = 1, exitAll = 0, serverTimeout = -1, serverFd = 4, 
numericHosts = 0, pollFds = 0x90b4f78, connections = 0x90b56e8, numConnections 
= 3, 
  handlers = {destructor = 0x805811c <serverDestroyHandlers>, arg = 0x0, key = 0x90660e0 "/quitinaboxd)", value = 0x0, idx = 1, ch = 0 '\000', children = 0x9066298, 
    numChildren = 7}, ssl = {enabled = 0, sslContext = 0x0, sniCertificatePattern = 0x0, generateMissing = 0, sniContexts = {
      destructor = 0x805948c <sslDestroyCachedContext>, arg = 0x9065e4c, key = 0x0, value = 0x0, idx = -1, ch = 0 '\000', children = 0x0, numChildren = 0}}}

---

Seems like httpConsumePayload() invoked from httpHandleConnection() to refill 
partial request. 

Added following line in httpHandleConnection() seems to fix the issue :
----
// If the callback only provided partial data, 
      // FIX 
      if( http->done == 0 &&  http->url == NULL && http->method == NULL && http->path == NULL &&
       http->matchedPath == NULL && http->pathInfo == NULL && http->query == NULL && http->version == NULL &&
       http->headerLength == 0 &&  http->callback == NULL &&  http->arg == NULL && http->totalWritten == 0 &&
        http->code == 200 && http->state == COMMAND )
        break;
      //FIX
       if (http->isPartialReply && (!http->msg || http->msgLength <= 0)) {
        httpConsumePayload(http, "", 0);

---------

Original issue reported on code.google.com by lakshmip...@gmail.com on 10 Mar 2013 at 4:25