kern_event.c (ace8398da0f88280810bae970996cf32d94dd310) | kern_event.c (397c19d1753d210247d77eb3ca33d1c7c1eb2fa9) |
---|---|
1/*- 2 * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> 3 * Copyright 2004 John-Mark Gurney <jmg@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 517 unchanged lines hidden (view full) --- 526 kq->kq_fdp = fdp; 527 knlist_init(&kq->kq_sel.si_note, &kq->kq_lock, NULL, NULL, NULL); 528 TASK_INIT(&kq->kq_task, 0, kqueue_task, kq); 529 530 FILEDESC_XLOCK(fdp); 531 SLIST_INSERT_HEAD(&fdp->fd_kqlist, kq, kq_list); 532 FILEDESC_XUNLOCK(fdp); 533 | 1/*- 2 * Copyright (c) 1999,2000,2001 Jonathan Lemon <jlemon@FreeBSD.org> 3 * Copyright 2004 John-Mark Gurney <jmg@FreeBSD.org> 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 517 unchanged lines hidden (view full) --- 526 kq->kq_fdp = fdp; 527 knlist_init(&kq->kq_sel.si_note, &kq->kq_lock, NULL, NULL, NULL); 528 TASK_INIT(&kq->kq_task, 0, kqueue_task, kq); 529 530 FILEDESC_XLOCK(fdp); 531 SLIST_INSERT_HEAD(&fdp->fd_kqlist, kq, kq_list); 532 FILEDESC_XUNLOCK(fdp); 533 |
534 FILE_LOCK(fp); 535 fp->f_flag = FREAD | FWRITE; 536 fp->f_type = DTYPE_KQUEUE; 537 fp->f_data = kq; 538 fp->f_ops = &kqueueops; 539 FILE_UNLOCK(fp); | 534 finit(fp, FREAD | FWRITE, DTYPE_KQUEUE, kq, &kqueueops); |
540 fdrop(fp, td); 541 542 td->td_retval[0] = fd; 543done2: 544 return (error); 545} 546 547#ifndef _SYS_SYSPROTO_H_ --- 437 unchanged lines hidden (view full) --- 985static int 986kqueue_acquire(struct file *fp, struct kqueue **kqp) 987{ 988 int error; 989 struct kqueue *kq; 990 991 error = 0; 992 | 535 fdrop(fp, td); 536 537 td->td_retval[0] = fd; 538done2: 539 return (error); 540} 541 542#ifndef _SYS_SYSPROTO_H_ --- 437 unchanged lines hidden (view full) --- 980static int 981kqueue_acquire(struct file *fp, struct kqueue **kqp) 982{ 983 int error; 984 struct kqueue *kq; 985 986 error = 0; 987 |
993 FILE_LOCK(fp); 994 do { 995 kq = fp->f_data; 996 if (fp->f_type != DTYPE_KQUEUE || kq == NULL) { 997 error = EBADF; 998 break; 999 } 1000 *kqp = kq; 1001 KQ_LOCK(kq); 1002 if ((kq->kq_state & KQ_CLOSING) == KQ_CLOSING) { 1003 KQ_UNLOCK(kq); 1004 error = EBADF; 1005 break; 1006 } 1007 kq->kq_refcnt++; | 988 kq = fp->f_data; 989 if (fp->f_type != DTYPE_KQUEUE || kq == NULL) 990 return (EBADF); 991 *kqp = kq; 992 KQ_LOCK(kq); 993 if ((kq->kq_state & KQ_CLOSING) == KQ_CLOSING) { |
1008 KQ_UNLOCK(kq); | 994 KQ_UNLOCK(kq); |
1009 } while (0); 1010 FILE_UNLOCK(fp); | 995 return (EBADF); 996 } 997 kq->kq_refcnt++; 998 KQ_UNLOCK(kq); |
1011 1012 return error; 1013} 1014 1015static void 1016kqueue_release(struct kqueue *kq, int locked) 1017{ 1018 if (locked) --- 947 unchanged lines hidden --- | 999 1000 return error; 1001} 1002 1003static void 1004kqueue_release(struct kqueue *kq, int locked) 1005{ 1006 if (locked) --- 947 unchanged lines hidden --- |