core/rpc: avoid double close

Reported by coverity as CID #1231253
plugins/rpc: fix a couple of memory leaks

Always free response, in the worst case we are freeing NULL which
is a NOP.
Reported by Coverity as CID #1231246, #1231245
plugins/rpc: cleanup duplicated code

Introduce a couple of helpers to reduce duplicated code.

Before:
   text	   data	    bss	    dec	    hex	filename
   9742	    180	      0	   9922	   26c2	plugins/rpc/rpc_plugin.o

After:
   text	   data	    bss	    dec	    hex	filename
   9230	    180	      0	   9410	   24c2	plugins/rpc/rpc_plugin.o

My compiler inlines so uwsgi_rpc_get_remote it does make difference
in practice still it makes the code prettier.
Merge pull request #689 from xrmx/rcpclean21

2.1: Rpc coverity fixes and plugin cleanup