Use fflush() before fsync() in rio.c.

Incremental flushing in rio.c is only used to avoid huge kernel buffers
synched to slow disks creating big latency spikes, so this fix has no
durability implications, however it is certainly more correct to make
sure that the FILE buffers are flushed to the kernel before calling
fsync on the file descriptor.

Thanks to Li Shao Kai for reporting this issue in the Redis mailing
list.
redis-cli: support for --scan option.
redis-cli --help output improved with --scan and periods.
Don't log MONITOR clients as disconnecting slaves.
Fixed inverted if condition in MISCONF error code path.
SENTINEL SET master quorum implemented.
Sentinel: check arity for SENTINEL MASTER command.

This fixes issue #1530.
Add support for listen(2) backlog definition

In high RPS environments, the default listen backlog is not sufficient, so
giving users the power to configure it is the right approach, especially
since it requires only minor modifications to the code.
Option "backlog" renamed "tcp-backlog".

This is especially important since we already have a concept of backlog
(the replication backlog).
Redis.conf comment about tcp-backlog option improved.
Test: fixed osx msg passing issue in testing framework.

The Redis test uses a server-clients model in order to parallelize the
execution of different tests. However in recent versions of osx not
setting the channel to a binary encoding caused issues even if AFAIK no
binary data is really sent via this channel. However now the channels
are deliberately set to a binary encoding and this solves the issue.

The exact issue was the test not terminating and giving the impression
of running forever, since test clients or servers were unable to
exchange the messages to continue.
update copyright year
Scripting: use mstime() and mstime_t for lua_time_start.

server.lua_time_start is expressed in milliseconds. Use mstime_t instead
of long long, and populate it with mstime() instead of ustime()/1000.

Functionally identical but more natural.
Allow CONFIG and SHUTDOWN while in stale-slave state.
Scripting: expire keys in scripts only at first access.

Keys expiring in the middle of the execution of Lua scripts are to
create inconsistencies in masters and / or AOF files. See the following
example:

    if redis.call("exists",KEYS[1]) == 1
    then
        redis.call("incr","mycounter")
    end

    if redis.call("exists",KEYS[1]) == 1
    then
        return redis.call("incr","mycounter")
    end

The script executes two times the same *if key exists then incrementcounter*
logic. However the two executions will work differently in the master and
the slaves, provided some unlucky timing happens.

In the master the first time the key may still exist, while the second time
the key may no longer exist. This will result in the key incremented just one
time. However as a side effect the master will generate a synthetic
`DEL` command in the replication channel in order to force the slaves to
expire the key (given that key expiration is master-driven).

When the same script will run in the slave, the key will no longer be
there, so the script will not increment the key.

The key idea used to implement the expire-at-first-lookup semantics was
provided by Marc Gravell.
Move mstime_t define outside sentinel.c.

The define is now used in other parts of Redis 2.8 tree instead of long
long.

A nice side effect is that now 2.8 and unstable sentinel.c files are
identical as it should be.
Redis 2.8.5.
Check for EAGAIN in sendBulkToSlave().

Sometime an osx master with a Linux server over a slow link caused
a strange error where osx called the writable function for
the socket but actually apparently there was no room in the socket
buffer to accept the write: write(2) call returned an EAGAIN error,
that was not checked, so we considered write(2) == 0 always as a connection
reset, which was unfortunate since the bulk transfer has to start again.

Also more errors are logged with the WARNING level in the same code path
now.
Sentinel: allow SHUTDOWN command in Sentinel mode.
Don't count time to feed MONITORs in SLOWLOG.