Proc refcnting wrappers
[akaros.git] / kern / src / arsc.c
index 6550b24..6fed271 100644 (file)
@@ -29,12 +29,12 @@ spinlock_t arsc_proc_lock = SPINLOCK_INITIALIZER;
 intreg_t inline syscall_async(struct proc *p, syscall_req_t *call)
 {
        return syscall(p, call->num, call->args[0], call->args[1],
 intreg_t inline syscall_async(struct proc *p, syscall_req_t *call)
 {
        return syscall(p, call->num, call->args[0], call->args[1],
-                      call->args[2], call->args[3], call->args[4]);
+                      call->args[2], call->args[3], call->args[4], call->args[5]);
 }
 
 intreg_t sys_init_arsc(struct proc *p)
 {
 }
 
 intreg_t sys_init_arsc(struct proc *p)
 {
-       kref_get(&p->kref, 1);          /* we're storing an external ref here */
+       proc_incref(p, 1);              /* we're storing an external ref here */
        spin_lock_irqsave(&arsc_proc_lock);
        TAILQ_INSERT_TAIL(&arsc_proc_list, p, proc_arsc_link);
        spin_unlock_irqsave(&arsc_proc_lock);
        spin_lock_irqsave(&arsc_proc_lock);
        TAILQ_INSERT_TAIL(&arsc_proc_list, p, proc_arsc_link);
        spin_unlock_irqsave(&arsc_proc_lock);
@@ -55,7 +55,7 @@ void arsc_server(struct trapframe *tf)
                        process_generic_syscalls (p, MAX_ASRC_BATCH); 
                        if (p->state == PROC_DYING) {
                                TAILQ_REMOVE(&arsc_proc_list, p, proc_arsc_link);
                        process_generic_syscalls (p, MAX_ASRC_BATCH); 
                        if (p->state == PROC_DYING) {
                                TAILQ_REMOVE(&arsc_proc_list, p, proc_arsc_link);
-                               kref_put(&p->kref);
+                               proc_decref(p);
                                /* Need to break out, so the TAILQ_FOREACH doesn't flip out.
                                 * It's not fair, but we're not dealing with that yet anyway */
                                break;
                                /* Need to break out, so the TAILQ_FOREACH doesn't flip out.
                                 * It's not fair, but we're not dealing with that yet anyway */
                                break;
@@ -94,9 +94,14 @@ static intreg_t process_generic_syscalls(struct proc *p, size_t max)
                // print req
                printd("req no %d, req arg %c\n", req->num, *((char*)req->args[0]));
                
                // print req
                printd("req no %d, req arg %c\n", req->num, *((char*)req->args[0]));
                
-               coreinfo->errno_loc = (int*)&(rsp.syserr);
+               /* TODO: when the remote syscall stuff can handle the new async
+                * syscalls, they need to use a real sysc.  This might at least stop it
+                * from crashing. */
+               struct syscall sysc = {0};
+               coreinfo->cur_sysc = &sysc;
                
                rsp.retval = syscall_async(p, req);
                
                rsp.retval = syscall_async(p, req);
+               rsp.syserr = sysc.err;
                // write response into the slot it came from
                memcpy(req, &rsp, sizeof(syscall_rsp_t));
                // update our counter for what we've produced (assumes we went in order!)
                // write response into the slot it came from
                memcpy(req, &rsp, sizeof(syscall_rsp_t));
                // update our counter for what we've produced (assumes we went in order!)