Roxen.git / server / etc / modules / AFS.pmod / Filesystem.pike

version» Context lines:

Roxen.git/server/etc/modules/AFS.pmod/Filesystem.pike:15:   // ActionFS stuff   //      // Client session management      mapping(string:AFS.ClientSession) client_sessions = ([]);   //! Mapping from session id to a ClientSession object. Use   //! @expr{@[REP.get_session()]->cs@} to get the session for the   //! current request.    + mapping(AFS.Types.ClientMessage:multiset(AFS.ClientSession.Subscription)) + client_subscriptions = ([]); +  +    mapping|int(0..0)|AFS.ClientSession    get_client_session(RequestID id, void|Roxen.OnError on_error)   //! Attempts to get an existing session or create a new one if   //! needed. The client must provide a session id in the HTTP - //! variable session-id. + //! variable session_id.   //!   //! @note - //! May return @expr{0@} or throw an error (depending on the @[on_error] - //! parameter) if no session ID was given in the session-id - //! variable. + //! May return @expr{0@} or throw an error (depending on the @[on_error] + //! parameter) if no session ID was given in the session_id variable.   //!   //! @param on_error - //! A @[Roxen.OnError] value that describes how the function - //! should handle errors. + //! A @[Roxen.OnError] value that describes how the function + //! should handle errors.   //!   //! @returns - //! A ClientSession object if successful, or an HTTP response - //! mapping if the session couldn't be found/used. In the case - //! of error the @[on_error] value will determine how the - //! function returns. + //! A ClientSession object if successful, or an HTTP response + //! mapping if the session couldn't be found/used. In the case + //! of error the @[on_error] value will determine how the + //! function returns.   {    string sid = id->variables["session_id"]; -  +     if (!sid)    return Roxen.raise_err(on_error, "No session id given!\n");       string session_hash = sprintf("%q", sid); // FIXME!    AFS.ClientSession cs = client_sessions[session_hash];       if (!cs) {    // We need to create a new session    if (mixed err = catch { -  cs = AFS.ClientSession(id)->reset_session(); +  cs = AFS.ClientSession(id, this, session_hash);    }) {   #ifdef DEBUG_CLIENT_SESSION_CREATION    werror("Unable to create session:\n%s\n",    describe_backtrace(err));   #endif /* DEBUG_CLIENT_SESSION_CREATION */    return Roxen.http_low_answer(401, "Unauthorized");    }       // Check the session table again in case of race.    // vvv Relying on the interpreter lock from here.    if (AFS.ClientSession cs2 = client_sessions[session_hash])    cs = cs2; -  else +  else {    client_sessions[session_hash] = cs;    // ^^^ Relying on the interpreter lock to here.    -  +  // Reset newly created session. To avoid unnecessarily inform the +  // client of this we inspect the AFS tag counter which should be very +  // low for a fresh login / reload. +  int afs_tag_num = (int) id->variables["tag"]; +  int(0..1) dont_inform_client = afs_tag_num && (afs_tag_num < 10); +  cs->reset_session(dont_inform_client); +  } +     return cs;       }       cs->reset_session_timer();    return cs;   }    - mapping(AFS.Types.ClientMessage:multiset(AFS.ClientSession.Subscription)) - client_subscriptions = ([]); -  +    //! Register all @expr{"filesystem-actions"@} provider modules.   //!   //! Typically called from @[start()] or @[ready_to_receive_requests()].   protected void init_action_modules(Configuration conf)   {    fs_actions = ([]);       // Scan configuration for AFS.Actions    foreach (conf->get_providers("filesystem-actions"), RoxenModule fsam) {    get_fs_actions(fsam);
Roxen.git/server/etc/modules/AFS.pmod/Filesystem.pike:131:       if (int timeout = args["timeout"]) {    if (timeout == -1) {    // Auto mode.    if (!zero_type (args->interval) &&    (args->interval != client_poll_interval))    cs->push_response (AFS.ClientMessages.poll,    ([ "poll_interval" : client_poll_interval ]),    tag);    -  return cs->set_notification_id(id, client_poll_timeout); +  return cs->set_notification_id(id, tag, client_poll_timeout);    } else { -  return cs->set_notification_id(id, timeout); +  return cs->set_notification_id(id, tag, timeout);    }    }       return 0;    }   }      //! A mapping of all known fs_actions that clients may use.   protected mapping(string:AFS.Action) fs_actions = ([   ]);