+ do {
+ if (($tok = @ftok(FTOK_PATH."/user".$id, "B")) == -1) {
+ log_main("ftok failed");
+ break;
+ }
+
+ if (($shm_sz = sharedmem_sz($tok)) == -1) {
+ log_main("shmop_open failed");
+ }
+
+ if ($shm_sz == -1)
+ $shm_sz = SHM_DIMS_U_MIN;
+
+ if ($shm = shm_attach($tok, $shm_sz)) {
+ $user = @shm_get_var($shm, $tok);
+
+ if ($sess != FALSE && $user->sess != $sess) {
+ break;
+ }
+ log_only("user == ".($user == FALSE ? "FALSE" : "TRUE")." user === ".($user === FALSE ? "FALSE" : "TRUE")." user isset ".(isset($user) ? "TRUE" : "FALSE"));
+
+ if ($user == FALSE) {
+ log_only("INIT MAIN DATA");
+
+ // SHSPLIT FIXME: init_data for User class ??
+ $user = User::create($id, "", "");
+ if (@shm_put_var($shm, $tok, $user) == FALSE) {
+ log_only("PUT_VAR FALLITA ".strlen(serialize($user)));
+ log_only(serialize($user));
+ }
+ }
+ else {
+ if ($sess != FALSE) {
+ /*
+ * NOTE: this part is for check only, theoretically
+ * user->step anch proxy_step are set allways at the same value
+ */
+ $old_step = $user->step;
+ $arr = User::load_step($sess);
+ $user->step = $arr['s'];
+ if ($old_step != $user->step) {
+ log_crit("steps are diffetents User->step ".$user->step." Old_step: ".$old_step);
+ }
+ }
+ }
+ $user->shm_sz = $shm_sz;
+
+ shm_detach($shm);
+ }
+
+ //
+ // SHSPLIT: load users from the shared memory
+ //
+ return ($user);
+ } while (0);
+
+ return (FALSE);