コード例 #1
0
static void
poll_fd_events_stop_watches(PollEvents *s)
{
  PollFdEvents *self = (PollFdEvents *) s;

  if (iv_fd_registered(&self->fd_watch))
    iv_fd_unregister(&self->fd_watch);
}
コード例 #2
0
ファイル: afsocket-dest.c プロジェクト: jbfuzier/syslog-ng
static gboolean
afsocket_dd_connected(AFSocketDestDriver *self)
{
  gchar buf1[256], buf2[256];
  int error = 0;
  socklen_t errorlen = sizeof(error);
  LogTransport *transport;
  LogProtoClient *proto;

  main_loop_assert_main_thread();

  if (iv_fd_registered(&self->connect_fd))
    iv_fd_unregister(&self->connect_fd);

  if (self->transport_mapper->sock_type == SOCK_STREAM)
    {
      if (getsockopt(self->fd, SOL_SOCKET, SO_ERROR, &error, &errorlen) == -1)
        {
          msg_error("getsockopt(SOL_SOCKET, SO_ERROR) failed for connecting socket",
                    evt_tag_int("fd", self->fd),
                    evt_tag_str("server", g_sockaddr_format(self->dest_addr, buf2, sizeof(buf2), GSA_FULL)),
                    evt_tag_errno(EVT_TAG_OSERROR, errno),
                    evt_tag_int("time_reopen", self->time_reopen),
                    NULL);
          goto error_reconnect;
        }
      if (error)
        {
          msg_error("Syslog connection failed",
                    evt_tag_int("fd", self->fd),
                    evt_tag_str("server", g_sockaddr_format(self->dest_addr, buf2, sizeof(buf2), GSA_FULL)),
                    evt_tag_errno(EVT_TAG_OSERROR, error),
                    evt_tag_int("time_reopen", self->time_reopen),
                    NULL);
          goto error_reconnect;
        }
    }
  msg_notice("Syslog connection established",
              evt_tag_int("fd", self->fd),
              evt_tag_str("server", g_sockaddr_format(self->dest_addr, buf2, sizeof(buf2), GSA_FULL)),
              evt_tag_str("local", g_sockaddr_format(self->bind_addr, buf1, sizeof(buf1), GSA_FULL)),
              NULL);

  transport = afsocket_dd_construct_transport(self, self->fd);
  if (!transport)
    goto error_reconnect;

  proto = log_proto_client_factory_construct(self->proto_factory, transport, &self->writer_options.proto_options.super);

  log_writer_reopen(self->writer, proto);
  return TRUE;
 error_reconnect:
  close(self->fd);
  self->fd = -1;
  afsocket_dd_start_reconnect_timer(self);
  return FALSE;
}
コード例 #3
0
ファイル: logreader.c プロジェクト: essodjolo/syslog-ng-3.4
static void
log_reader_stop_watches(LogReader *self)
{
  if (iv_fd_registered(&self->fd_watch))
    iv_fd_unregister(&self->fd_watch);
  if (iv_timer_registered(&self->follow_timer))
    iv_timer_unregister(&self->follow_timer);
  if (iv_task_registered(&self->restart_task))
    iv_task_unregister(&self->restart_task);
}
コード例 #4
0
ファイル: iv_popen_test.c プロジェクト: RustinCohle/ivykis
static void done(struct req *req, int timeout)
{
	iv_popen_request_close(&req->popen_req);

	iv_fd_unregister(&req->popen_fd);
	close(req->popen_fd.fd);

	if (!timeout)
		iv_timer_unregister(&req->closeit);
}
コード例 #5
0
void
control_server_unix_free(ControlServer *s)
{
  ControlServerUnix *self = (ControlServerUnix *)s;
  if (iv_fd_registered(&self->control_listen))
    {
      iv_fd_unregister(&self->control_listen);
    }
  if (self->control_socket != -1)
    {
      close(self->control_socket);
    }
}
コード例 #6
0
static gboolean
_is_fd_pollable(gint fd)
{
    struct iv_fd check_fd;
    gboolean pollable;

    IV_FD_INIT(&check_fd);
    check_fd.fd = fd;
    check_fd.cookie = NULL;

    pollable = (iv_fd_register_try(&check_fd) == 0);
    if (pollable)
        iv_fd_unregister(&check_fd);
    return pollable;
}
コード例 #7
0
ファイル: afsocket-dest.c プロジェクト: black-perl/syslog-ng
static void
afsocket_dd_stop_watches(AFSocketDestDriver *self)
{
  main_loop_assert_main_thread();

  if (iv_fd_registered(&self->connect_fd))
    {
      iv_fd_unregister(&self->connect_fd);

      /* need to close the fd in this case as it wasn't established yet */
      msg_verbose("Closing connecting fd",
                  evt_tag_int("fd", self->fd));
      close(self->fd);
    }
  if (iv_timer_registered(&self->reconnect_timer))
    iv_timer_unregister(&self->reconnect_timer);
}
コード例 #8
0
ファイル: logwriter.c プロジェクト: tiltti/syslog-ng-3.4
static void
log_writer_stop_watches(LogWriter *self)
{
  if (self->watches_running)
    {
      if (iv_timer_registered(&self->suspend_timer))
        iv_timer_unregister(&self->suspend_timer);
      if (iv_fd_registered(&self->fd_watch))
        iv_fd_unregister(&self->fd_watch);
      if (iv_task_registered(&self->immed_io_task))
        iv_task_unregister(&self->immed_io_task);

      log_queue_reset_parallel_push(self->queue);

      self->watches_running = FALSE;
    }
}
コード例 #9
0
ファイル: http_client.c プロジェクト: bazsi/ivykis-http
static void abort_me(struct http_client_request *req, int close_fd,
		     int callback)
{
	// @@@ cancel hostname lookup
	if (req->hostname_lookup_callback_scheduled)
		iv_task_unregister(&req->hostname_lookup);

	free(req->redirect);
	free(req->redirect_last);

	if (req->fd.fd != -1) {
		iv_fd_unregister(&req->fd);
		if (close_fd) {
			close(req->fd.fd);
			req->fd.fd = -1;
		}
	}

	if (callback)
		req->handler(req->cookie);
}
コード例 #10
0
ファイル: afsocket-source.c プロジェクト: gyula/syslog-ng-3.5
static void
afsocket_sd_stop_watches(AFSocketSourceDriver *self)
{
  if (iv_fd_registered (&self->listen_fd))
    iv_fd_unregister(&self->listen_fd);
}
コード例 #11
0
ファイル: http_client.c プロジェクト: bazsi/ivykis-http
static void got_data(void *_req)
{
	struct http_client_request *req = (struct http_client_request *)_req;
	int bytes_left;
	char *ptr;
	int size;

	ptr = req->rcvbuf + req->read_ptr;
	size = sizeof(req->rcvbuf) - req->read_ptr;

	bytes_left = recv(req->fd.fd, ptr, size, MSG_PEEK);
	if (bytes_left == 0) {
		req->state = ECONNABORTED;
		abort_me(req, 1, 1);
		return;
	}

	if (bytes_left < 0) {
		if (errno != EAGAIN) {
			req->state = errno;
			abort_me(req, 1, 1);
		}
		return;
	}

	req->read_ptr += bytes_left;
	process_data(req);

	if (req->state == EINPROGRESS)
		return;

	// @@@ check http status code too?
	if (req->state == 0 && req->redirect != NULL) {
		char *host;
		int port;
		char *url;

		if (!req->recursion_limit--) {
			req->state = ELOOP;
			abort_me(req, 1, 1);
			return;
		}

		if (split_url(req->redirect, &host, &port, &url) < 0) {
			req->state = EINVAL;
			abort_me(req, 1, 1);
			return;
		}

		req->redirect_hostname = host;
		req->redirect_port = port;
		req->redirect_url = url;

		free(req->redirect_last);
		req->redirect_last = req->redirect;
		req->redirect = NULL;

		iv_fd_unregister(&req->fd);
		close(req->fd.fd);
		req->fd.fd = -1;
		req->state = EINPROGRESS;
		start_hostname_lookup(req);

		return;
	}

	abort_me(req, !!req->state, 1);
}
コード例 #12
0
ファイル: control.c プロジェクト: essodjolo/syslog-ng-3.4
static void
control_connection_stop_watches(ControlConnection *self)
{
  iv_fd_unregister(&self->control_io);
}
コード例 #13
0
ファイル: afsocket.c プロジェクト: ndzou/syslog-ng-3.3
static gboolean
afsocket_dd_connected(AFSocketDestDriver *self)
{
  gchar buf1[256], buf2[256];
  int error = 0;
  socklen_t errorlen = sizeof(error);
  LogTransport *transport;
  LogProto *proto;
  guint32 transport_flags = 0;

  main_loop_assert_main_thread();

  if (iv_fd_registered(&self->connect_fd))
    iv_fd_unregister(&self->connect_fd);

  if (self->flags & AFSOCKET_STREAM)
    {
      transport_flags |= LTF_SHUTDOWN;
      if (getsockopt(self->fd, SOL_SOCKET, SO_ERROR, &error, &errorlen) == -1)
        {
          msg_error("getsockopt(SOL_SOCKET, SO_ERROR) failed for connecting socket",
                    evt_tag_int("fd", self->fd),
                    evt_tag_str("server", g_sockaddr_format(self->dest_addr, buf2, sizeof(buf2), GSA_FULL)),
                    evt_tag_errno(EVT_TAG_OSERROR, errno),
                    evt_tag_int("time_reopen", self->time_reopen),
                    NULL);
          goto error_reconnect;
        }
      if (error)
        {
          msg_error("Syslog connection failed",
                    evt_tag_int("fd", self->fd),
                    evt_tag_str("server", g_sockaddr_format(self->dest_addr, buf2, sizeof(buf2), GSA_FULL)),
                    evt_tag_errno(EVT_TAG_OSERROR, error),
                    evt_tag_int("time_reopen", self->time_reopen),
                    NULL);
          goto error_reconnect;
        }
    }
  msg_notice("Syslog connection established",
              evt_tag_int("fd", self->fd),
              evt_tag_str("server", g_sockaddr_format(self->dest_addr, buf2, sizeof(buf2), GSA_FULL)),
              evt_tag_str("local", g_sockaddr_format(self->bind_addr, buf1, sizeof(buf1), GSA_FULL)),
              NULL);


#if ENABLE_SSL
  if (self->tls_context)
    {
      TLSSession *tls_session;

      tls_session = tls_context_setup_session(self->tls_context);
      if (!tls_session)
        {
          goto error_reconnect;
        }

      tls_session_set_verify(tls_session, afsocket_dd_tls_verify_callback, self, NULL);
      transport = log_transport_tls_new(tls_session, self->fd, transport_flags);
    }
  else
#endif
    transport = log_transport_plain_new(self->fd, transport_flags);

  if (self->flags & AFSOCKET_SYSLOG_PROTOCOL)
    {
      if (self->flags & AFSOCKET_STREAM)
        proto = log_proto_framed_client_new(transport);
      else
        proto = log_proto_text_client_new(transport);
    }
  else
    {
      proto = log_proto_text_client_new(transport);
    }

  log_writer_reopen(self->writer, proto);
  return TRUE;
 error_reconnect:
  close(self->fd);
  self->fd = -1;
  afsocket_dd_start_reconnect_timer(self);
  return FALSE;
}
コード例 #14
0
void
control_connection_stop_watches(ControlConnection *s)
{
  ControlConnectionUnix *self = (ControlConnectionUnix *)s;
  iv_fd_unregister(&self->control_io);
}