spinlock_lock(&SOCK_CTL.slock);
+ if(SOCK_CTL.in_use == 0){
+
+ printf("sockctl not in use\n");
+
+ spinlock_unlock(&SOCK_CTL.slock);
+
+ return NULL;
+ }
+
int i = make_hash(fd, SOCK_CTL.size);
ctx = SOCK_CTL.SOCK_CTX[i];
spinlock_lock(&SOCK_CTL.slock);
+ if(SOCK_CTL.in_use == 0){
+
+ printf("sockctl not in use\n");
+
+ spinlock_unlock(&SOCK_CTL.slock);
+
+ return -1;
+ }
+
int i = make_hash(fd, SOCK_CTL.size);
ctx = SOCK_CTL.SOCK_CTX[i];
spinlock_lock(&SOCK_CTL.slock);
+ if(SOCK_CTL.in_use == 0){
+
+ printf("sockctl not in use\n");
+
+ spinlock_unlock(&SOCK_CTL.slock);
+
+ return -1;
+ }
+
+
int i = make_hash(fd, SOCK_CTL.size);
ctx = SOCK_CTL.SOCK_CTX[i];
int init_all(){
+
for(int i = 0 ; i < MAX_CONN;i ++){
CHAN_CTX[i].ssl = NULL;
}
+ SOCK_CTL.in_use = 1;
spinlock_init(&SOCK_CTL.slock);
return 0;
}
+int free_all(){
+
+ spinlock_lock(&SOCK_CTL.slock);
+
+ SOCK_CTL.in_use = 0;
+
+ for(int i = 0; i < SOCK_CTL.size; i++){
+
+ free(SOCK_CTL.SOCK_CTX[i]);
+
+ free(SOCK_CTL.SOCK_CTX_LOCK[i]);
+
+ }
+
+ free(SOCK_CTL.SOCK_CTX);
+
+ free(SOCK_CTL.SOCK_CTX_LOCK);
+
+ spinlock_unlock(&SOCK_CTL.slock);
+}
void sock_listen_and_serve(void* varg){