Commits

Anonymous committed 00562ef Draft

must switch to context before inspecting it, lol

  • Participants
  • Parent commits 7c3b9ed

Comments (0)

Files changed (1)

     return 0;
   }
 
+  printf("gonna create the image\n");
+
   z->state = CONTEXT_CLOSED;
   z->img = create_image(imgname);
 
+  printf("gonna check the return value\n");
+
   switch (z->img.status) {
   case SHM_ERR:
     PyErr_SetString(Create, "SHM_ERR");
   case SHM_ERR_MMAP:
     PyErr_SetString(Mmap, "SHM_ERR_MMAP");
     return 0;
-  }
+ }
+
+  printf("setting state to WRITEABLE you idiot bitch\n");
 
   z->state = CONTEXT_WRITEABLE;
   switch_to_context(z);
 
+  printf("hurf durf\n");
+
   pyamt_image *i = allocator(sizeof(pyamt_image));
   if (!i) {
     PyErr_SetString(Error, alloc_exception);
   i->roots = 0;
   i->pq_free = 0;
 
+  printf("amt_new?\n");
+
   /* if the prior allocation worked, we'll have to trust the next one does */
   amt_new();
 
+  printf("amt_new!\n");
+
   return PyCObject_FromVoidPtrAndDesc(z, pyamt_context_desc, pyamt_context_dest);
 }
 
 
   if (!PyArg_ParseTuple(args, "s|i", &imgname, mode))
     return 0;
-
+  
   pyamt_context *z = calloc(sizeof(pyamt_context), 1);
   if (!z) {
     PyErr_SetString(MODE_ERR, "ran out of memory while allocating pyamt_context");
   if (!PyArg_ParseTuple(args, "Os#", &z, &key, &keylen))
     return 0;
 
+  switch_to_context(z);
+
   switch (z->state) {
   case CONTEXT_CLOSED:
     PyErr_SetString(Error, "amt context is closed");
     return 0;
   }
 
-  switch_to_context(z);
   ensure_valid_root(z);
   
   void *result;
   if (!PyArg_ParseTuple(args, "Os#s#", &z, &key, &keylen, &val, &vallen))
     return 0;
 
+  switch_to_context(z);
+
   switch (z->state) {
   case CONTEXT_CLOSED:
     PyErr_SetString(Error, "amt context is closed");
     return 0;
   }
 
-  switch_to_context(z);
-
   /* writing has to be performed by atomically reading the current root,
      performing a full amt insertion, and then performing a CAS against
      the old root. there should probably be a limited number of retries
   if (!PyArg_ParseTuple(args, "Os#", &z, &key, &keylen))
     return 0;
 
+  switch_to_context(z);
+
   switch (z->state) {
   case CONTEXT_CLOSED:
     PyErr_SetString(Error, "amt context is closed");
     return 0;
   }
 
-  switch_to_context(z);
-
-
   /* the same logic used for writing new keys must be used for removing them */