[Sheepdog] [PATCH RESEND] sheep: use sys_stat_* helper to check status

Liu Yuan namei.unix at gmail.com
Mon Nov 21 11:33:42 CET 2011


On 11/21/2011 06:20 PM, Christoph Hellwig wrote:

> On Thu, Nov 17, 2011 at 06:03:21PM +0800, Liu Yuan wrote:
>> From: Liu Yuan <tailai.ly at taobao.com>
>>
>>
>> Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
>> ---
>>  sheep/sdnet.c |    2 +-
>>  sheep/sheep.c |    2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/sheep/sdnet.c b/sheep/sdnet.c
>> index a8ea295..053ee8d 100644
>> --- a/sheep/sdnet.c
>> +++ b/sheep/sdnet.c
>> @@ -549,7 +549,7 @@ static void listen_handler(int listen_fd, int events, void *data)
>>  	int fd, ret;
>>  	struct client_info *ci;
>>  
>> -	if (sys->status == SD_STATUS_SHUTDOWN) {
>> +	if (sys_stat_shutdown()) {
> 
> I've never really understood what helpers like this are supposed to
> buy us.  The original code seems to be much cleared in showing what
> it actually does.  Also if we want to do clean switch statements on
> the state we'll need to dereferene it directly anyway.
> 


Umm, it is supposed to abstract out system status and system flags low
level usage and higher level code like sys_can_recover() can base on
these helpers. Anyway, '==' is error-proen to be written as '='.

It is not that useful, especially for switch statement.

The idea behind these helpers is that, we don't use raw sys->status &&
|| operations to mean if system can recover, if system can get
halted...provide a simple helper like sys_can_recover() for people to use.

Thanks,
Yuan



More information about the sheepdog mailing list