You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Chris Darroch (JIRA)" <ji...@apache.org> on 2009/02/17 23:32:59 UTC

[jira] Created: (ZOOKEEPER-319) add locking around auth info in zhandle_t

add locking around auth info in zhandle_t
-----------------------------------------

                 Key: ZOOKEEPER-319
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-319
             Project: Zookeeper
          Issue Type: Bug
          Components: c client
    Affects Versions: 3.1.0, 3.0.1, 3.0.0
            Reporter: Chris Darroch
             Fix For: 3.1.1, 3.2.0


Looking over the zookeeper.c code it appears to me that the zoo_add_auth() function may be called at any time by the user in their "main" thread.  This function alters the elements of the auth_info structure in the zhandle_t structure.

Meanwhile, the IO thread may read those elements at any time in such functions as send_auth_info() and auth_completion_func().  It seems important, then, to add a lock which prevents data being read by the IO thread while only partially changed by the user's thread.  The attached patch add such a lock.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-319) add locking around auth info in zhandle_t

Posted by "Chris Darroch (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Darroch updated ZOOKEEPER-319:
------------------------------------

    Attachment:     (was: ZOOKEEPER-319.patch)

> add locking around auth info in zhandle_t
> -----------------------------------------
>
>                 Key: ZOOKEEPER-319
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-319
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0, 3.0.1, 3.1.0
>            Reporter: Chris Darroch
>             Fix For: 3.1.1, 3.2.0
>
>         Attachments: ZOOKEEPER-319.patch
>
>
> Looking over the zookeeper.c code it appears to me that the zoo_add_auth() function may be called at any time by the user in their "main" thread.  This function alters the elements of the auth_info structure in the zhandle_t structure.
> Meanwhile, the IO thread may read those elements at any time in such functions as send_auth_info() and auth_completion_func().  It seems important, then, to add a lock which prevents data being read by the IO thread while only partially changed by the user's thread.  The attached patch add such a lock.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (ZOOKEEPER-319) add locking around auth info in zhandle_t

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Hunt reassigned ZOOKEEPER-319:
--------------------------------------

    Assignee: Chris Darroch

> add locking around auth info in zhandle_t
> -----------------------------------------
>
>                 Key: ZOOKEEPER-319
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-319
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0, 3.0.1, 3.1.0
>            Reporter: Chris Darroch
>            Assignee: Chris Darroch
>             Fix For: 3.1.1, 3.2.0
>
>         Attachments: ZOOKEEPER-319.patch, ZOOKEEPER-319.patch, ZOOKEEPER-319.patch
>
>
> Looking over the zookeeper.c code it appears to me that the zoo_add_auth() function may be called at any time by the user in their "main" thread.  This function alters the elements of the auth_info structure in the zhandle_t structure.
> Meanwhile, the IO thread may read those elements at any time in such functions as send_auth_info() and auth_completion_func().  It seems important, then, to add a lock which prevents data being read by the IO thread while only partially changed by the user's thread.  The attached patch add such a lock.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-319) add locking around auth info in zhandle_t

Posted by "Chris Darroch (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Darroch updated ZOOKEEPER-319:
------------------------------------

    Attachment: ZOOKEEPER-319.patch

Good points -- see if this suits.

> add locking around auth info in zhandle_t
> -----------------------------------------
>
>                 Key: ZOOKEEPER-319
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-319
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0, 3.0.1, 3.1.0
>            Reporter: Chris Darroch
>             Fix For: 3.1.1, 3.2.0
>
>         Attachments: ZOOKEEPER-319.patch, ZOOKEEPER-319.patch, ZOOKEEPER-319.patch
>
>
> Looking over the zookeeper.c code it appears to me that the zoo_add_auth() function may be called at any time by the user in their "main" thread.  This function alters the elements of the auth_info structure in the zhandle_t structure.
> Meanwhile, the IO thread may read those elements at any time in such functions as send_auth_info() and auth_completion_func().  It seems important, then, to add a lock which prevents data being read by the IO thread while only partially changed by the user's thread.  The attached patch add such a lock.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-319) add locking around auth info in zhandle_t

Posted by "Mahadev konar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mahadev konar updated ZOOKEEPER-319:
------------------------------------

    Attachment: ZOOKEEPER-319.patch

just a minor modification. my compiler fails on compiliing 
consta char* auth_data without initialization.

+1 to the patch.

one minor nit -- 
- we have some logging in auth_completion_func() in zookeeper.c

{noformat}
 zoo_lock_auth(zh);
    
    if(rc!=0){
        LOG_ERROR(("Authentication scheme %s failed. Connection closed.",
                zh->auth.scheme));
        zh->state=ZOO_AUTH_FAILED_STATE;
    }else{
        zh->auth.state=1;  // active
        LOG_INFO(("Authentication scheme %s succeeded", zh->auth.scheme));
    }

    if (zh->auth.completion) {
        auth_completion = zh->auth.completion;
        auth_data = zh->auth.data;
        zh->auth.completion=0;
    }

    zoo_unlock_auth(zh);
{noformat}
Should we get rid of logging within the lock?


> add locking around auth info in zhandle_t
> -----------------------------------------
>
>                 Key: ZOOKEEPER-319
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-319
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0, 3.0.1, 3.1.0
>            Reporter: Chris Darroch
>             Fix For: 3.1.1, 3.2.0
>
>         Attachments: ZOOKEEPER-319.patch, ZOOKEEPER-319.patch
>
>
> Looking over the zookeeper.c code it appears to me that the zoo_add_auth() function may be called at any time by the user in their "main" thread.  This function alters the elements of the auth_info structure in the zhandle_t structure.
> Meanwhile, the IO thread may read those elements at any time in such functions as send_auth_info() and auth_completion_func().  It seems important, then, to add a lock which prevents data being read by the IO thread while only partially changed by the user's thread.  The attached patch add such a lock.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-319) add locking around auth info in zhandle_t

Posted by "Chris Darroch (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Darroch updated ZOOKEEPER-319:
------------------------------------

    Attachment: ZOOKEEPER-319.patch

> add locking around auth info in zhandle_t
> -----------------------------------------
>
>                 Key: ZOOKEEPER-319
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-319
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0, 3.0.1, 3.1.0
>            Reporter: Chris Darroch
>             Fix For: 3.1.1, 3.2.0
>
>         Attachments: ZOOKEEPER-319.patch
>
>
> Looking over the zookeeper.c code it appears to me that the zoo_add_auth() function may be called at any time by the user in their "main" thread.  This function alters the elements of the auth_info structure in the zhandle_t structure.
> Meanwhile, the IO thread may read those elements at any time in such functions as send_auth_info() and auth_completion_func().  It seems important, then, to add a lock which prevents data being read by the IO thread while only partially changed by the user's thread.  The attached patch add such a lock.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-319) add locking around auth info in zhandle_t

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12677685#action_12677685 ] 

Hudson commented on ZOOKEEPER-319:
----------------------------------

Integrated in ZooKeeper-trunk #243 (See [http://hudson.zones.apache.org/hudson/job/ZooKeeper-trunk/243/])
    . add locking around auth info in zhandle_t. (chris darroch via mahadev)


> add locking around auth info in zhandle_t
> -----------------------------------------
>
>                 Key: ZOOKEEPER-319
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-319
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0, 3.0.1, 3.1.0
>            Reporter: Chris Darroch
>            Assignee: Chris Darroch
>             Fix For: 3.1.1, 3.2.0
>
>         Attachments: ZOOKEEPER-319.patch, ZOOKEEPER-319.patch, ZOOKEEPER-319.patch
>
>
> Looking over the zookeeper.c code it appears to me that the zoo_add_auth() function may be called at any time by the user in their "main" thread.  This function alters the elements of the auth_info structure in the zhandle_t structure.
> Meanwhile, the IO thread may read those elements at any time in such functions as send_auth_info() and auth_completion_func().  It seems important, then, to add a lock which prevents data being read by the IO thread while only partially changed by the user's thread.  The attached patch add such a lock.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-319) add locking around auth info in zhandle_t

Posted by "Chris Darroch (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Darroch updated ZOOKEEPER-319:
------------------------------------

    Status: Patch Available  (was: Open)

> add locking around auth info in zhandle_t
> -----------------------------------------
>
>                 Key: ZOOKEEPER-319
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-319
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.1.0, 3.0.1, 3.0.0
>            Reporter: Chris Darroch
>             Fix For: 3.1.1, 3.2.0
>
>         Attachments: ZOOKEEPER-319.patch
>
>
> Looking over the zookeeper.c code it appears to me that the zoo_add_auth() function may be called at any time by the user in their "main" thread.  This function alters the elements of the auth_info structure in the zhandle_t structure.
> Meanwhile, the IO thread may read those elements at any time in such functions as send_auth_info() and auth_completion_func().  It seems important, then, to add a lock which prevents data being read by the IO thread while only partially changed by the user's thread.  The attached patch add such a lock.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-319) add locking around auth info in zhandle_t

Posted by "Chris Darroch (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Chris Darroch updated ZOOKEEPER-319:
------------------------------------

    Attachment: ZOOKEEPER-319.patch

This version avoids holding the auth lock while calling the user's auth completion function (which may run for a long time; we don't know).

> add locking around auth info in zhandle_t
> -----------------------------------------
>
>                 Key: ZOOKEEPER-319
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-319
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0, 3.0.1, 3.1.0
>            Reporter: Chris Darroch
>             Fix For: 3.1.1, 3.2.0
>
>         Attachments: ZOOKEEPER-319.patch, ZOOKEEPER-319.patch
>
>
> Looking over the zookeeper.c code it appears to me that the zoo_add_auth() function may be called at any time by the user in their "main" thread.  This function alters the elements of the auth_info structure in the zhandle_t structure.
> Meanwhile, the IO thread may read those elements at any time in such functions as send_auth_info() and auth_completion_func().  It seems important, then, to add a lock which prevents data being read by the IO thread while only partially changed by the user's thread.  The attached patch add such a lock.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-319) add locking around auth info in zhandle_t

Posted by "Mahadev konar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-319?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mahadev konar updated ZOOKEEPER-319:
------------------------------------

      Resolution: Fixed
    Hadoop Flags: [Reviewed]
          Status: Resolved  (was: Patch Available)

I just committed this. thanks chris.

> add locking around auth info in zhandle_t
> -----------------------------------------
>
>                 Key: ZOOKEEPER-319
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-319
>             Project: Zookeeper
>          Issue Type: Bug
>          Components: c client
>    Affects Versions: 3.0.0, 3.0.1, 3.1.0
>            Reporter: Chris Darroch
>            Assignee: Chris Darroch
>             Fix For: 3.1.1, 3.2.0
>
>         Attachments: ZOOKEEPER-319.patch, ZOOKEEPER-319.patch, ZOOKEEPER-319.patch
>
>
> Looking over the zookeeper.c code it appears to me that the zoo_add_auth() function may be called at any time by the user in their "main" thread.  This function alters the elements of the auth_info structure in the zhandle_t structure.
> Meanwhile, the IO thread may read those elements at any time in such functions as send_auth_info() and auth_completion_func().  It seems important, then, to add a lock which prevents data being read by the IO thread while only partially changed by the user's thread.  The attached patch add such a lock.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.