~ubuntu-branches/ubuntu/precise/crossroads/precise

« back to all changes in this revision

Viewing changes to xr/sys/socketclose.cc

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ritter
  • Date: 2010-07-05 16:27:00 UTC
  • Revision ID: james.westby@ubuntu.com-20100705162700-0g08tfav8ee9y51u
Tags: upstream-2.65
ImportĀ upstreamĀ versionĀ 2.65

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "sys"
 
2
#include "../config/config"
 
3
 
 
4
void socketclose (int fd) {
 
5
    PROFILE("socketclose");
 
6
 
 
7
    if (fd > 2) {
 
8
        debugmsg ((Mstr("Closing socket ") + fd) + "\n");
 
9
 
 
10
        if (config.fastclose()) {
 
11
            struct linger l;
 
12
            l.l_onoff = 1;
 
13
            l.l_linger = 2;
 
14
            setsockopt (fd, SOL_SOCKET, SO_LINGER, &l, sizeof(l));
 
15
        }
 
16
        shutdown(fd, SHUT_RDWR);
 
17
        close(fd);
 
18
    }
 
19
}