Exemplo n.º 1
0
/*
 * DESCRIPTION
 *   send slave dump cmd
 *   format : slave.info\n,filter.tables,\0ringbuf_sleep_usec(binary)
 *   eaxmplae : /data/mysql-bin.00001,0\n,test.test,\01000(binary)
 *
 *
 */
static int rs_send_dumpcmd(rs_slave_info_t *si)
{
    int32_t l;
    ssize_t n;
    l = rs_strlen(si->dump_info) + 2 + rs_strlen(si->filter_tables) + 2 + 4;
    char buf[4 + l], *p;

    p = buf;

    p = rs_cpymem(buf, &l, 4);
    if(snprintf(p, l + 1, "%s\n,%s,%c", si->dump_info, si->filter_tables, 0)
            < 0)
    {
        rs_log_error(RS_LOG_ERR, rs_errno, "snprintf() failed");
        return RS_ERR;
    }

    rs_memcpy(p + l - 4, &(si->rb_esusec), 4);

    n = rs_write(si->svr_fd, buf, 4 + l);

    if(n != 4 + l) {
        return RS_ERR;
    }

    return RS_OK;
}
Exemplo n.º 2
0
int
rs_write_char(FILE *savef, char c)
{
    if (write_error)
        return(WRITESTAT);

    rs_write(savef, &c, 1);

    return(WRITESTAT);
}
Exemplo n.º 3
0
int
rs_write_chars(FILE *savef, char *c, int count)
{
    if (write_error)
        return(WRITESTAT);

    rs_write_int(savef, count);
    rs_write(savef, c, count);

    return(WRITESTAT);
}
Exemplo n.º 4
0
int
rs_write_boolean(FILE *savef, int c)
{
    unsigned char buf = (c == 0) ? 0 : 1;
    
    if (write_error)
        return(WRITESTAT);

    rs_write(savef, &buf, 1);

    return(WRITESTAT);
}
Exemplo n.º 5
0
int
rs_write_ushort(FILE *savef, unsigned short c)
{
    unsigned char bytes[2];
    unsigned char *buf = (unsigned char *) &c;

    if (write_error)
        return(WRITESTAT);

    if (big_endian)
    {
        bytes[1] = buf[0];
        bytes[0] = buf[1];
        buf = bytes;
    }

    rs_write(savef, buf, 2);

    return(WRITESTAT);
}
Exemplo n.º 6
0
int rs_create_pidfile(char *name)
{
    char    pid_str[INT32_LEN + 1];
    int     len, fd;
    ssize_t n;

    len = 0;
    fd = -1;

    if(name == NULL) {
        name = rs_pid_path;
    }

    fd = open(name, O_CREAT | O_TRUNC | O_WRONLY, 00644);

    if(fd == -1) {
        rs_log_error(RS_LOG_ERR, rs_errno, "open(\"%s\") failed", name);
        return RS_ERR;
    }

    len = snprintf(pid_str, INT32_LEN + 1, "%d\n", rs_pid);

    if(len < 0) {
        rs_log_error(RS_LOG_ERR, rs_errno, "snprintf() failed");
        return RS_ERR;
    }

    n = rs_write(fd, pid_str, len);

    if(n != len) {
        return RS_ERR;
    }

    if(close(fd) != 0) {
        rs_log_error(RS_LOG_ERR, rs_errno, "close() failed");
    }

    return RS_OK;
}
Exemplo n.º 7
0
int
rs_write_int(FILE *savef, int c)
{
    unsigned char bytes[4];
    unsigned char *buf = (unsigned char *) &c;

    if (write_error)
        return(WRITESTAT);

    if (big_endian)
    {
        bytes[3] = buf[0];
        bytes[2] = buf[1];
        bytes[1] = buf[2];
        bytes[0] = buf[3];
        buf = bytes;
    }
    
    rs_write(savef, buf, 4);

    return(WRITESTAT);
}
static int rs_put_char(struct tty_struct *tty, unsigned char ch)
{
	return rs_write(tty, &ch, 1);
}
static void rs_put_char(struct tty_struct *tty, char ch)
{
	rs_write(tty, 1, &ch, 1);
}