コード例 #1
0
ファイル: driver.c プロジェクト: k6dsp/gsl1680
void zoom(struct i2c_client *cliente,int value) {

	struct input_event ev;

	memset(&ev, 0, sizeof(struct input_event));
	ev.type = EV_KEY;
	ev.code = KEY_LEFTCTRL;
	ev.value = 1;
	write(cliente->mfile, &ev, sizeof(struct input_event));
	do_sync(cliente,cliente->mfile);

	memset(&ev, 0, sizeof(struct input_event));
	ev.type = EV_REL;
	ev.code = REL_WHEEL;
	ev.value = value;
	write(cliente->mfile, &ev, sizeof(struct input_event));
	do_sync(cliente,cliente->mfile);

	memset(&ev, 0, sizeof(struct input_event));
	ev.type = EV_KEY;
	ev.code = KEY_LEFTCTRL;
	ev.value = 0;
	write(cliente->mfile, &ev, sizeof(struct input_event));
	do_sync(cliente,cliente->mfile);
}
コード例 #2
0
ファイル: driver.c プロジェクト: k6dsp/gsl1680
void menu_ctrl(struct i2c_client *cliente) {

	struct input_event ev;

	memset(&ev, 0, sizeof(struct input_event));
	ev.type = EV_KEY;
	ev.code = KEY_LEFTCTRL;
	ev.value = 1;
	write(cliente->mfile, &ev, sizeof(struct input_event));
	do_sync(cliente,cliente->mfile);

	memset(&ev, 0, sizeof(struct input_event));
	ev.type = EV_KEY;
	ev.code = KEY_COMPOSE;
	ev.value = 1;
	write(cliente->mfile, &ev, sizeof(struct input_event));
	do_sync(cliente,cliente->mfile);

	memset(&ev, 0, sizeof(struct input_event));
	ev.type = EV_KEY;
	ev.code = KEY_COMPOSE;
	ev.value = 0;
	write(cliente->mfile, &ev, sizeof(struct input_event));
	do_sync(cliente,cliente->mfile);

	memset(&ev, 0, sizeof(struct input_event));
	ev.type = EV_KEY;
	ev.code = KEY_LEFTCTRL;
	ev.value = 0;
	write(cliente->mfile, &ev, sizeof(struct input_event));
	do_sync(cliente,cliente->mfile);

}
コード例 #3
0
ファイル: misc.c プロジェクト: CesarBallardini/minix3
/*===========================================================================*
 *				pm_reboot				     *
 *===========================================================================*/
PUBLIC void pm_reboot()
{
  /* Perform the VFS side of the reboot call. */
  int i;
  struct fproc *rfp;

  do_sync();

  /* Do exit processing for all leftover processes and servers,
   * but don't actually exit them (if they were really gone, PM
   * will tell us about it).
   */
  for (i = 0; i < NR_PROCS; i++) {
	rfp = &fproc[i];
	if (rfp->fp_endpoint == NONE) continue;

	/* Don't just free the proc right away, but let it finish what it was
	 * doing first */
	lock_proc(rfp, 0);
	free_proc(rfp, 0);
	unlock_proc(rfp);
  }

  do_sync();
  unmount_all();
}
コード例 #4
0
ファイル: wbuft.c プロジェクト: pcherenkov/bsl45-misc.tools
static ssize_t
write_nbuf (int fd, const char* buf, size_t len, const struct test_spec* sp)
{
    size_t i;
    ssize_t nwr = -1, ntotal = 0;
    int err = 0;

    assert (buf && sp);

    if (0 == (sp->mode_flags & SEQ_WRITE))
        if (-1 == lseek (fd, 0, SEEK_SET)) {
            err = errno;
            perror ("lseek");
            return -err;
        }
    for (i = 0; i < sp->niter; ++i) {
        nwr = write (fd, buf, len);
        if (nwr != (ssize_t)len) {
            err = errno;
            (void) fprintf (stderr, "%s: wrote %ld bytes out of %ld: err=%d [%s]\n",
                __func__, (long)nwr, len, err, (err ? strerror(err) : "none"));
            break;
        }

        if (sp->mode_flags & SYNC_TYPE) {
            do_sync (fd, sp->mode_flags);
        }
        ntotal += nwr;
    }

    return !err ? ntotal : -err;
}
コード例 #5
0
ファイル: websocket.hpp プロジェクト: LocutusOfBorg/poedit
    explicit
    ws_echo_server(
        std::ostream& log,
        kind k = kind::sync)
        : log_(log)
        , work_(ioc_.get_executor())
        , ts_(ioc_)
        , ws_(ts_)
    {
        beast::websocket::permessage_deflate pmd;
        pmd.server_enable = true;
        pmd.server_max_window_bits = 9;
        pmd.compLevel = 1;
        ws_.set_option(pmd);

        switch(k)
        {
        case kind::sync:
            t_ = std::thread{[&]{ do_sync(); }};
            break;

        case kind::async:
            t_ = std::thread{[&]{ ioc_.run(); }};
            do_accept();
            break;

        case kind::async_client:
            t_ = std::thread{[&]{ ioc_.run(); }};
            break;
        }
    }
コード例 #6
0
ファイル: misc.c プロジェクト: mwilbur/minix
/*===========================================================================*
 *				do_fsync				     *
 *===========================================================================*/
PUBLIC int do_fsync()
{
/* Perform the fsync() system call. For now, don't be unnecessarily smart. */

  do_sync();
  return(OK);
}
コード例 #7
0
ファイル: misc.c プロジェクト: mwilbur/minix
/*===========================================================================*
 *				pm_reboot				     *
 *===========================================================================*/
PUBLIC void pm_reboot()
{
  /* Perform the FS side of the reboot call. */
  int i;

  do_sync();

  SANITYCHECK;

  /* Do exit processing for all leftover processes and servers,
   * but don't actually exit them (if they were really gone, PM
   * will tell us about it).
   */
  for (i = 0; i < NR_PROCS; i++)
	if((m_in.endpt1 = fproc[i].fp_endpoint) != NONE) {
		/* No FP_EXITING, just free the resources, otherwise
		 * consistency check for fp_endpoint (set to NONE) will
		 * fail if process wants to do something in the (short)
		 * future.
		 */
		free_proc(&fproc[i], 0);
	}
  SANITYCHECK;

  unmount_all();

  SANITYCHECK;

}
コード例 #8
0
ファイル: misc.c プロジェクト: jkiiski/minix
/*===========================================================================*
 *				pm_reboot				     *
 *===========================================================================*/
void pm_reboot()
{
/* Perform the VFS side of the reboot call. */
  int i;
  struct fproc *rfp;

  do_sync();

  /* Do exit processing for all leftover processes and servers, but don't
   * actually exit them (if they were really gone, PM will tell us about it).
   * Skip processes that handle parts of the file system; we first need to give
   * them the chance to unmount (which should be possible as all normal
   * processes have no open files anymore).
   */
  for (i = 0; i < NR_PROCS; i++) {
	rfp = &fproc[i];

	/* Don't just free the proc right away, but let it finish what it was
	 * doing first */
	lock_proc(rfp, 0);
	if (rfp->fp_endpoint != NONE && find_vmnt(rfp->fp_endpoint) == NULL)
		free_proc(rfp, 0);
	unlock_proc(rfp);
  }

  do_sync();
  unmount_all(0 /* Don't force */);

  /* Try to exit all processes again including File Servers */
  for (i = 0; i < NR_PROCS; i++) {
	rfp = &fproc[i];

	/* Don't just free the proc right away, but let it finish what it was
	 * doing first */
	lock_proc(rfp, 0);
	if (rfp->fp_endpoint != NONE)
		free_proc(rfp, 0);
	unlock_proc(rfp);
  }

  do_sync();
  unmount_all(1 /* Force */);

}
コード例 #9
0
ファイル: wbuft.c プロジェクト: pcherenkov/bsl45-misc.tools
static ssize_t
writev_nbuf (int fd, const char* buf, size_t len, const struct test_spec* sp)
{
    size_t i = 0, j = 0;
    ssize_t chunk_len = 0, nwr = -1, ntotal = 0, nleft = (ssize_t)len;
    int err = 0;
    struct iovec* iov = NULL;
    const char *p = buf;

    assert (buf && sp);
    assert ((sp->num_chunks > 1) && (sp->num_chunks < len));

    chunk_len = (ssize_t)(len / sp->num_chunks);
    assert (chunk_len >= 1);

    if (0 == (sp->mode_flags & SEQ_WRITE))
        if (-1 == lseek (fd, 0, SEEK_SET)) {
            err = errno;
            perror ("lseek");
            return -err;
        }

    iov = calloc (sp->num_chunks, sizeof(iov[0]));
    if (!iov) {
        (void) fputs ("calloc for iov failed\n", stderr);
        return -1;
    }

    for (i = 0; (i < sp->num_chunks) && (nleft > 0); ++i) {
        iov[i].iov_base = (char*)p;
        iov[i].iov_len = ((i + 1) < sp->num_chunks)
                        ? (size_t)chunk_len : (size_t)nleft;

        p += iov[i].iov_len;
        nleft -= iov[i].iov_len;
    }
    assert (0 == nleft);

    for (j = 0; j < sp->niter; ++j) {
        nwr = writev (fd, iov, sp->num_chunks);
        if (nwr != (ssize_t)len) {
            err = errno;
            (void) fprintf (stderr, "%s: wrote %ld bytes out of %ld: err=%d [%s]\n",
                __func__, (long)nwr, len, err, (err ? strerror(err) : "none"));
            break;
        }

        if (sp->mode_flags & SYNC_TYPE) {
            do_sync (fd, sp->mode_flags);
        }
        ntotal += nwr;
    }

    free (iov);
    return !err ? ntotal : -err;
}
コード例 #10
0
ファイル: driver.c プロジェクト: k6dsp/gsl1680
void click_r(struct i2c_client *cliente,int press) {

	struct input_event ev;
	memset(&ev, 0, sizeof(struct input_event));

	ev.type = EV_KEY;
	ev.code = BTN_RIGHT;
	ev.value = press;
	write(cliente->mfile, &ev, sizeof(struct input_event));

	do_sync(cliente,cliente->mfile);
}
コード例 #11
0
ファイル: driver.c プロジェクト: k6dsp/gsl1680
void scrollh(struct i2c_client *cliente,int value) {

	struct input_event ev;
	memset(&ev, 0, sizeof(struct input_event));

	ev.type = EV_REL;
	ev.code = REL_HWHEEL;
	ev.value = value;
	write(cliente->mfile, &ev, sizeof(struct input_event));

	do_sync(cliente,cliente->mfile);
}
コード例 #12
0
ファイル: evazlibdeflator.c プロジェクト: novator24/libeva
static gboolean
do_background_flush (gpointer def)
{
  EvaZlibDeflator *zlib_deflator = EVA_ZLIB_DEFLATOR (def);
  GError *error = NULL;
  if (!do_sync (zlib_deflator, Z_SYNC_FLUSH, &error))
    {
      eva_io_set_gerror (EVA_IO (zlib_deflator),
			 EVA_IO_ERROR_SYNC,
			 error);
    }
  zlib_deflator->flush_source = NULL;
  return FALSE;
}
コード例 #13
0
ファイル: httppoll.cpp プロジェクト: studzien/iris
HttpPoll::HttpPoll(QObject *parent)
:ByteStream(parent)
{
	d = new Private(this);

	d->polltime = 30;
	d->t = new QTimer(this);
	d->t->setSingleShot(true);
	connect(d->t, SIGNAL(timeout()), SLOT(do_sync()));

	connect(&d->http, SIGNAL(result()), SLOT(http_result()));
	connect(&d->http, SIGNAL(error(int)), SLOT(http_error(int)));

	reset(true);
}
コード例 #14
0
CassandraStore::ResultCode
Store::delete_old_call_fragments_sync(const std::string& impu,
                                      const std::vector<CallFragment> fragments,
                                      const int64_t cass_timestamp,
                                      SAS::TrailId trail)
{
  DeleteOldCallFragments* op = new_delete_old_call_fragments_op(impu,
                                                                fragments,
                                                                cass_timestamp);
  do_sync(op, trail);
  CassandraStore::ResultCode result = op->get_result_code();

  delete op; op = NULL;
  return result;
}
コード例 #15
0
static void check_transfer(rtems_task_priority prio, bool waiter)
{
  rtems_bdbuf_buffer *bd = do_read('I');

  if (waiter) {
    create_waiter();
  }

  activate_purger(prio);

  do_sync('I', bd);

  if (waiter) {
    restore_waiter();
  }
}
コード例 #16
0
CassandraStore::ResultCode
Store::get_call_fragments_sync(const std::string& impu,
                               std::vector<CallFragment>& fragments,
                               SAS::TrailId trail)
{
  GetCallFragments* op = new_get_call_fragments_op(impu);

  if (do_sync(op, trail))
  {
    op->get_result(fragments);
  }

  CassandraStore::ResultCode result = op->get_result_code();

  delete op; op = NULL;
  return result;
}
コード例 #17
0
ファイル: main.c プロジェクト: z0x010/rdesktop
static void
process_cmds(void)
{
	char line[VCHANNEL_MAX_LINE];
	int size;

	char *p, *tok1, *tok2, *tok3, *tok4, *tok5, *tok6, *tok7, *tok8;

	while ((size = g_vchannel_read_fn(line, sizeof(line))) >= 0) {

		p = unescape(line);

		tok1 = get_token(&p);
		tok2 = get_token(&p);
		tok3 = get_token(&p);
		tok4 = get_token(&p);
		tok5 = get_token(&p);
		tok6 = get_token(&p);
		tok7 = get_token(&p);
		tok8 = get_token(&p);

		if (strcmp(tok1, "SYNC") == 0)
			do_sync();
		else if (strcmp(tok1, "STATE") == 0)
			do_state(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL,
						0)), strtol(tok4, NULL, 0));
		else if (strcmp(tok1, "POSITION") == 0)
			do_position(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL,
						0)), strtol(tok4, NULL, 0), strtol(tok5, NULL, 0),
				strtol(tok6, NULL, 0), strtol(tok7, NULL, 0));
		else if (strcmp(tok1, "ZCHANGE") == 0)
			do_zchange(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL,
						0)), long_to_hwnd(strtoul(tok4, NULL, 0)));
		else if (strcmp(tok1, "FOCUS") == 0)
			do_focus(strtoul(tok2, NULL, 0), long_to_hwnd(strtoul(tok3, NULL,
						0)));
		else if (strcmp(tok1, "DESTROY") == 0)
			do_destroy(long_to_hwnd(strtoul(tok3, NULL, 0)));
		else if (strcmp(tok1, "SPAWN") == 0)
			do_spawn(strtoul(tok2, NULL, 0), tok3);
		else if (strcmp(tok1, "PERSISTENT") == 0)
			do_persistent(strtoul(tok2, NULL, 0), strtol(tok3, NULL, 0));

		free(p);
	}
}
コード例 #18
0
ファイル: evazlibdeflator.c プロジェクト: novator24/libeva
static gboolean
eva_zlib_deflator_shutdown_write (EvaIO      *io,
				  GError    **error)
{
  EvaZlibDeflator *zlib_deflator = EVA_ZLIB_DEFLATOR (io);
  if (!do_sync (EVA_ZLIB_DEFLATOR (io), Z_FINISH, error))
    return FALSE;
  if (zlib_deflator->flush_source != NULL)
    {
      eva_source_remove (zlib_deflator->flush_source);
      zlib_deflator->flush_source = NULL;
    }
  if (zlib_deflator->compressed.size == 0)
    eva_io_notify_read_shutdown (zlib_deflator);
  else
    eva_io_mark_idle_notify_read (zlib_deflator);
  return TRUE;
}
コード例 #19
0
CassandraStore::ResultCode
Store::write_call_fragment_sync(const std::string& impu,
                                const CallFragment& fragment,
                                const int64_t cass_timestamp,
                                const int32_t ttl,
                                SAS::TrailId trail)
{
  WriteCallFragment* op = new_write_call_fragment_op(impu,
                                                     fragment,
                                                     cass_timestamp,
                                                     ttl);

  do_sync(op, trail);
  CassandraStore::ResultCode result = op->get_result_code();

  delete op; op = NULL;
  return result;
}
コード例 #20
0
ファイル: gskzlibdeflator.c プロジェクト: davebenson/gsk
static gboolean
gsk_zlib_deflator_shutdown_write (GskIO      *io,
				  GError    **error)
{
  GskZlibDeflator *zlib_deflator = GSK_ZLIB_DEFLATOR (io);
  if (!do_sync (GSK_ZLIB_DEFLATOR (io), Z_FINISH, error))
    return FALSE;
  if (zlib_deflator->flush_source != NULL)
    {
      gsk_source_remove (zlib_deflator->flush_source);
      zlib_deflator->flush_source = NULL;
    }
  if (zlib_deflator->compressed.size == 0)
    gsk_io_notify_read_shutdown (zlib_deflator);
  else
    gsk_io_mark_idle_notify_read (zlib_deflator);
  return TRUE;
}
コード例 #21
0
ファイル: sync_client.c プロジェクト: thomasjfox/cyrus-imapd
static int do_sync_filename(const char *filename)
{
    sync_log_reader_t *slr;
    int r;

    if ((filename == NULL) || !strcmp(filename, "-"))
        slr = sync_log_reader_create_with_fd(0);    /* STDIN */
    else
        slr = sync_log_reader_create_with_filename(filename);

    r = sync_log_reader_begin(slr);
    if (!r)
        r = do_sync(slr);

    sync_log_reader_end(slr);
    sync_log_reader_free(slr);
    return r;
}
コード例 #22
0
ファイル: driver.c プロジェクト: k6dsp/gsl1680
void move_to(struct i2c_client *cliente,int x, int y) {

	struct input_event ev;

	memset(&ev, 0, sizeof(struct input_event));
	ev.type = EV_ABS;
	ev.code = ABS_X;
	ev.value = x;
	write(cliente->ufile, &ev, sizeof(struct input_event));
		
	memset(&ev, 0, sizeof(struct input_event));
	ev.type = EV_ABS;
	ev.code = ABS_Y;
	ev.value = y;
	write(cliente->ufile, &ev, sizeof(struct input_event));

	do_sync(cliente,cliente->ufile);
}
コード例 #23
0
ファイル: clocks-init.c プロジェクト: 10x-Amin/nAa-kernel
void init_clocks(void)
{
	/* Kill any active DMAs as they may trigger external memory accesses
	 * in the middle of reprogramming things, and that'll screw us up.
	 * For example, any automatic DMAs left by U-Boot for splash screens.
	 */
	size_t i;
	for (i = 0; i < MAX_DMA_CHANNELS; ++i) {
		struct dma_register *dma = dma_io_base_addr[i];
		dma->cfg = 0;
	}

	do_sync();

#ifdef SIC_IWR0
	bfin_write_SIC_IWR0(IWR_ENABLE(0));
# ifdef SIC_IWR1
	/* BF52x system reset does not properly reset SIC_IWR1 which
	 * will screw up the bootrom as it relies on MDMA0/1 waking it
	 * up from IDLE instructions.  See this report for more info:
	 * http://blackfin.uclinux.org/gf/tracker/4323
	 */
	if (ANOMALY_05000435)
		bfin_write_SIC_IWR1(IWR_ENABLE(10) | IWR_ENABLE(11));
	else
		bfin_write_SIC_IWR1(IWR_DISABLE_ALL);
# endif
# ifdef SIC_IWR2
	bfin_write_SIC_IWR2(IWR_DISABLE_ALL);
# endif
#else
	bfin_write_SIC_IWR(IWR_ENABLE(0));
#endif
	do_sync();
#ifdef EBIU_SDGCTL
	bfin_write_EBIU_SDGCTL(bfin_read_EBIU_SDGCTL() | SRFS);
	do_sync();
#endif

#ifdef CLKBUFOE
	bfin_write16(VR_CTL, bfin_read_VR_CTL() | CLKBUFOE);
	do_sync();
	__asm__ __volatile__("IDLE;");
#endif
	bfin_write_PLL_LOCKCNT(0x300);
	do_sync();
	bfin_write16(PLL_CTL, PLL_CTL_VAL);
	__asm__ __volatile__("IDLE;");
	bfin_write_PLL_DIV(CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
#ifdef EBIU_SDGCTL
	bfin_write_EBIU_SDRRC(mem_SDRRC);
	bfin_write_EBIU_SDGCTL((bfin_read_EBIU_SDGCTL() & SDGCTL_WIDTH) | mem_SDGCTL);
#else
	bfin_write_EBIU_RSTCTL(bfin_read_EBIU_RSTCTL() & ~(SRREQ));
	do_sync();
	bfin_write_EBIU_RSTCTL(bfin_read_EBIU_RSTCTL() | 0x1);
	bfin_write_EBIU_DDRCTL0(mem_DDRCTL0);
	bfin_write_EBIU_DDRCTL1(mem_DDRCTL1);
	bfin_write_EBIU_DDRCTL2(mem_DDRCTL2);
#ifdef CONFIG_MEM_EBIU_DDRQUE
	bfin_write_EBIU_DDRQUE(CONFIG_MEM_EBIU_DDRQUE);
#endif
#endif
	do_sync();
	bfin_read16(0);
}
コード例 #24
0
void *do_sync_fun(void *) {
    while (!sync_thr_shutdown) {
        do_sync();
    }
    return NULL;
}
コード例 #25
0
ファイル: misc.c プロジェクト: Hooman3/minix
/*===========================================================================*
 *				pm_reboot				     *
 *===========================================================================*/
void pm_reboot()
{
/* Perform the VFS side of the reboot call. This call is performed from the PM
 * process context.
 */
  message m_out;
  int i, r;
  struct fproc *rfp, *pmfp;

  pmfp = fp;

  do_sync();

  /* Do exit processing for all leftover processes and servers, but don't
   * actually exit them (if they were really gone, PM will tell us about it).
   * Skip processes that handle parts of the file system; we first need to give
   * them the chance to unmount (which should be possible as all normal
   * processes have no open files anymore).
   */
  /* This is the only place where we allow special modification of "fp". The
   * reboot procedure should really be implemented as a PM message broadcasted
   * to all processes, so that each process will be shut down cleanly by a
   * thread operating on its behalf. Doing everything here is simpler, but it
   * requires an exception to the strict model of having "fp" be the process
   * that owns the current worker thread.
   */
  for (i = 0; i < NR_PROCS; i++) {
	rfp = &fproc[i];

	/* Don't just free the proc right away, but let it finish what it was
	 * doing first */
	if (rfp != fp) lock_proc(rfp);
	if (rfp->fp_endpoint != NONE && find_vmnt(rfp->fp_endpoint) == NULL) {
		worker_set_proc(rfp);	/* temporarily fake process context */
		free_proc(0);
		worker_set_proc(pmfp);	/* restore original process context */
	}
	if (rfp != fp) unlock_proc(rfp);
  }

  do_sync();
  unmount_all(0 /* Don't force */);

  /* Try to exit all processes again including File Servers */
  for (i = 0; i < NR_PROCS; i++) {
	rfp = &fproc[i];

	/* Don't just free the proc right away, but let it finish what it was
	 * doing first */
	if (rfp != fp) lock_proc(rfp);
	if (rfp->fp_endpoint != NONE) {
		worker_set_proc(rfp);	/* temporarily fake process context */
		free_proc(0);
		worker_set_proc(pmfp);	/* restore original process context */
	}
	if (rfp != fp) unlock_proc(rfp);
  }

  do_sync();
  unmount_all(1 /* Force */);

  /* Reply to PM for synchronization */
  memset(&m_out, 0, sizeof(m_out));

  m_out.m_type = VFS_PM_REBOOT_REPLY;

  if ((r = ipc_send(PM_PROC_NR, &m_out)) != OK)
	panic("pm_reboot: ipc_send failed: %d", r);
}
コード例 #26
0
ファイル: httppoll.cpp プロジェクト: studzien/iris
void HttpPoll::http_result()
{
	// check for death :)
	QPointer<QObject> self = this;
	syncFinished();
	if(!self)
		return;

	// get id and packet
	QString id;
	QString cookie = d->http.getHeader("Set-Cookie");
	int n = cookie.indexOf("ID=");
	if(n == -1) {
		reset();
		error(ErrRead);
		return;
	}
	n += 3;
	int n2 = cookie.indexOf(';', n);
	if(n2 != -1)
		id = cookie.mid(n, n2-n);
	else
		id = cookie.mid(n);
	QByteArray block = d->http.body();

	// session error?
	if(id.right(2) == ":0") {
		if(id == "0:0" && d->state == 2) {
			reset();
			connectionClosed();
			return;
		}
		else {
			reset();
			error(ErrRead);
			return;
		}
	}

	d->ident = id;
	bool justNowConnected = false;
	if(d->state == 1) {
		d->state = 2;
		justNowConnected = true;
	}

	// sync up again soon
	if(bytesToWrite() > 0 || !d->closing) {
		d->t->start(d->polltime * 1000);
  }

	// connecting
	if(justNowConnected) {
		connected();
	}
	else {
		if(!d->out.isEmpty()) {
			int x = d->out.size();
			d->out.resize(0);
			takeWrite(x);
			bytesWritten(x);
		}
	}

	if(!self)
		return;

	if(!block.isEmpty()) {
		appendRead(block);
		readyRead();
	}

	if(!self)
		return;

	if(bytesToWrite() > 0) {
		do_sync();
	}
	else {
		if(d->closing) {
			reset();
			delayedCloseFinished();
			return;
		}
	}
}
コード例 #27
0
ファイル: httppoll.cpp プロジェクト: studzien/iris
int HttpPoll::tryWrite()
{
	if(!d->http.isActive())
		do_sync();
	return 0;
}
コード例 #28
0
ファイル: sync_client.c プロジェクト: thomasjfox/cyrus-imapd
static int do_daemon_work(const char *channel, const char *sync_shutdown_file,
                   unsigned long timeout, unsigned long min_delta,
                   int *restartp)
{
    int r = 0;
    time_t session_start;
    time_t single_start;
    int    delta;
    struct stat sbuf;
    sync_log_reader_t *slr;

    *restartp = RESTART_NONE;
    slr = sync_log_reader_create_with_channel(channel);

    session_start = time(NULL);

    while (1) {
        single_start = time(NULL);

        signals_poll();

        /* Check for shutdown file */
        if (sync_shutdown_file && !stat(sync_shutdown_file, &sbuf)) {
            unlink(sync_shutdown_file);
            break;
        }

        /* See if its time to RESTART */
        if ((timeout > 0) &&
            ((single_start - session_start) > (time_t) timeout)) {
            *restartp = RESTART_NORMAL;
            break;
        }

        r = sync_log_reader_begin(slr);
        if (r) {
            /* including specifically r == IMAP_AGAIN */
            if (min_delta > 0) {
                sleep(min_delta);
            } else {
                usleep(100000);    /* 1/10th second */
            }
            continue;
        }

        /* Process the work log */
        if ((r=do_sync(slr))) {
            syslog(LOG_ERR,
                   "Processing sync log file %s failed: %s",
                   sync_log_reader_get_file_name(slr), error_message(r));
            break;
        }

        r = sync_log_reader_end(slr);
        if (r) break;

        delta = time(NULL) - single_start;

        if (((unsigned) delta < min_delta) && ((min_delta-delta) > 0))
            sleep(min_delta-delta);
    }
    sync_log_reader_free(slr);

    if (*restartp == RESTART_NORMAL) {
        r = do_restart();
        if (r) {
            syslog(LOG_ERR, "sync_client RESTART failed: %s",
                   error_message(r));
        } else {
            syslog(LOG_INFO, "sync_client RESTART succeeded");
        }
        r = 0;
    }

    return(r);
}
コード例 #29
0
ファイル: snmp_threadsync.c プロジェクト: AKuHAK/ps2sdk
snmp_err_t
snmp_threadsync_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance)
{
  return do_sync(root_oid, root_oid_len, instance, get_next_instance_synced);
}
コード例 #30
0
asmlinkage long sys_sync(void)
{
	do_sync(1);
	return 0;
}