william-os4y/fapws3 — Issue #34: Wrong REMOTE_ADDR/fapws.remote_addr reported
Author: yangzhe1990
Created: 2012-03-02 04:08:30+00:00
State: open

I find this problem on a heavily loaded web server running python-bottle 0.10.7-1 on Debian, with fapws3 0.10.dev.

At first I post a bug report at bottle: https://github.com/defnull/bottle/issues/290, but then I find it's really a fapws3 bug:

I wrote the simple test script:

#!/usr/bin/env python

import fapws._evwsgi as evwsgi
from fapws import base

def start():
evwsgi.start('0.0.0.0', '8000')
evwsgi.set_base_module(base)

def hello(environ, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return ['%s\n%s\n' % (environ['REMOTE_ADDR'], environ['fapws.remote_addr'])]

evwsgi.wsgi_cb(('/', hello))

evwsgi.set_debug(0)
evwsgi.run()

if __name__ == '__main__':
start()

Then, by frequent execution of curl, I got

~$ curl http://localhost:8000/
127.0.0.1
127.0.0.1
~$ curl http://localhost:8000/
127.0.0.1
127.0.0.1
~$ curl http://localhost:8000/
127.0.0.1
127.0.0.1
~$ curl http://localhost:8000/ & curl http://10.20.1.50:8000
[1] 26257
127.0.0.1
127.0.0.1
127.0.0.1
127.0.0.1
[1]+ DONE curl http://localhost:8000/

and sometimes

~$ curl http://localhost:8000/ & curl http://10.20.1.50:8000
[4] 26331
10.20.1.50
10.20.1.50
10.20.1.50
10.20.1.50