~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/listen_tcp.cc

  • Committer: Andrew Hutchings
  • Date: 2011-02-07 17:20:59 UTC
  • mfrom: (2148 staging)
  • mto: (2148.2.3 build)
  • mto: This revision was merged to the branch mainline in revision 2149.
  • Revision ID: andrew@linuxjedi.co.uk-20110207172059-dyeahrgzrlincoe3
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
  {
57
57
    if ((accept_error_count++ & 255) == 0)
58
58
    {
59
 
      errmsg_printf(error::ERROR, _("accept() failed with errno %d"),
60
 
                    errno);
 
59
      sql_perror(_("accept() failed with errno %d"));
61
60
    }
62
61
 
63
62
    if (errno == ENFILE || errno == EMFILE)
123
122
      ret= setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &flags, sizeof(flags));
124
123
      if (ret != 0)
125
124
      {
126
 
        errmsg_printf(error::ERROR,
127
 
                      _("setsockopt(IPV6_V6ONLY) failed with errno %d"),
128
 
                      errno);
 
125
        sql_perror(_("setsockopt(IPV6_V6ONLY)"));
129
126
        return true;
130
127
      }
131
128
    }
134
131
    ret= fcntl(fd, F_SETFD, FD_CLOEXEC);
135
132
    if (ret != 0 || !(fcntl(fd, F_GETFD, 0) & FD_CLOEXEC))
136
133
    {
137
 
      errmsg_printf(error::ERROR,
138
 
                    _("fcntl(FD_CLOEXEC) failed with errno %d"),
139
 
                    errno);
 
134
      sql_perror(_("fcntl(FD_CLOEXEC)"));
140
135
      return true;
141
136
    }
142
137
 
143
138
    ret= setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &flags, sizeof(flags));
144
139
    if (ret != 0)
145
140
    {
146
 
      errmsg_printf(error::ERROR,
147
 
                    _("setsockopt(SO_REUSEADDR) failed with errno %d"),
148
 
                    errno);
 
141
      sql_perror(_("setsockopt(SO_REUSEADDR)"));
149
142
      return true;
150
143
    }
151
144
 
152
145
    ret= setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &flags, sizeof(flags));
153
146
    if (ret != 0)
154
147
    {
155
 
      errmsg_printf(error::ERROR,
156
 
                    _("setsockopt(SO_KEEPALIVE) failed with errno %d"),
157
 
                    errno);
 
148
      sql_perror(_("setsockopt(SO_KEEPALIVE)"));
158
149
      return true;
159
150
    }
160
151
 
161
152
    ret= setsockopt(fd, SOL_SOCKET, SO_LINGER, &ling, sizeof(ling));
162
153
    if (ret != 0)
163
154
    {
164
 
      errmsg_printf(error::ERROR,
165
 
                    _("setsockopt(SO_LINGER) failed with errno %d"),
166
 
                    errno);
 
155
      sql_perror(_("setsockopt(SO_LINGER)"));
167
156
      return true;
168
157
    }
169
158
 
170
159
    ret= setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flags, sizeof(flags));
171
160
    if (ret != 0)
172
161
    {
173
 
      errmsg_printf(error::ERROR,
174
 
                    _("setsockopt(TCP_NODELAY) failed with errno %d"),
175
 
                    errno);
 
162
      sql_perror(_("setsockopt(TCP_NODELAY)"));
176
163
      return true;
177
164
    }
178
165
 
192
179
        break;
193
180
      }
194
181
 
195
 
      errmsg_printf(error::INFO, _("Retrying bind() on %u\n"), getPort());
 
182
      errmsg_printf(error::INFO, _("Retrying bind() on %u"), getPort());
196
183
      this_wait= retry * retry / 3 + 1;
197
184
      sleep(this_wait);
198
185
    }
199
186
 
200
187
    if (ret < 0)
201
188
    {
202
 
      errmsg_printf(error::ERROR, _("bind() failed with errno: %d\n"),
203
 
                    errno);
204
 
      errmsg_printf(error::ERROR,
205
 
                    _("Do you already have another drizzled running?\n"));
 
189
      sql_perror(_("bind() Do you already have another drizzled running?"));
206
190
      return true;
207
191
    }
208
192
 
214
198
 
215
199
    fds.push_back(fd);
216
200
 
217
 
    errmsg_printf(error::INFO, _("Listening on %s:%s\n"), host_buf,
 
201
    errmsg_printf(error::INFO, _("Listening on %s:%s"), host_buf,
218
202
                  port_buf);
219
203
  }
220
204