libsmbclient: Connection reset by peer when reconnecting to a host.

derrell at samba.org derrell at samba.org
Thu Nov 10 23:19:04 GMT 2005


Tim Hutt <tdh29 at cam.ac.uk> writes:

> Hi,
>
> I've written a simple smb search engine that crawls some subnets (172.31.
> [57-60,65].*) on my network.
>
> Unfortunately after it has gone through one scan any subsequent connection 
> attempts say connection reset by peer.
>

Would you please submit this as a bug in http://bugzilla.samba.org.  Assign it
to component 'libsmbclient'.  Please attach your test program and your
application output to the bug.  I'll look into it.

I suspect that file descriptors are being exhausted.  It's not actually
occurring on the first repeat of an IP address.  According to your program
output, three IP addresses were rescannned before failures began.

For now, you might get around this problem by calling smbc_free_context() at
the end of each main loop iteration (after you've scanned each address once).
smbc_free_context(), among other things, cleans out the cache of open
connections if you give it TRUE as the second parameter; it forces
disconnection of all open connections.

To try this, if you're currently calling smbc_init() once at the beginning of
your application (rather than calling the lower-level smbc_init_context()),
you'll need to do something like this at the end of your main loop:

  context = smbc_set_context(NULL);     /* retrieve current context */
  smbc_free_context(context, TRUE);     /* close all cached connections */
  if (smbc_init(your_auth_data_fn, debug_level) != 0) {
          printf("We've got problems\n");
          /* Handle the error */
  }

If you're already calling smbc_init_context() at the beginning of your
application, then of course you should pass that context to
smbc_free_context(), and re-issue your initialization steps including
smbc_init_context().

Please indicate in the bugzilla report if the above helped solve the problem,
to narrow down what I need to look at.

Cheers,

Derrell


More information about the samba-technical mailing list