equal
deleted
inserted
replaced
20 |
20 |
21 #ifndef _FDESC_H |
21 #ifndef _FDESC_H |
22 #define _FDESC_H |
22 #define _FDESC_H |
23 |
23 |
24 #include <e32std.h> |
24 #include <e32std.h> |
25 #include <e32atomics.h> |
|
26 #include <e32cons.h> |
25 #include <e32cons.h> |
27 #include <f32file.h> |
26 #include <f32file.h> |
28 #include <es_sock.h> |
27 #include <es_sock.h> |
29 #include <c32comm.h> |
28 #include <c32comm.h> |
30 #include <stddef.h> |
29 #include <stddef.h> |
63 #define RFILE RFile |
62 #define RFILE RFile |
64 #define FSIZE TInt |
63 #define FSIZE TInt |
65 |
64 |
66 #endif //SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS |
65 #endif //SYMBIAN_OE_LARGE_FILE_SUPPORT && !SYMBIAN_OE_NO_LFS |
67 |
66 |
68 // Atomic socket operations support |
|
69 |
|
70 #define ATOMICSOCKETOP(realcall,on_error) \ |
|
71 { \ |
|
72 if (__e32_atomic_tau_ord32((void *)&iCount, 0x8000, 0, 1) >= 0x8000) \ |
|
73 { \ |
|
74 on_error; \ |
|
75 } \ |
|
76 else \ |
|
77 { \ |
|
78 realcall; \ |
|
79 __e32_atomic_tas_ord32((void *)&iCount, 0, -1, 0); \ |
|
80 } \ |
|
81 } |
|
82 |
|
83 #define NOP |
|
84 |
67 |
85 //Enumarations for Polling |
68 //Enumarations for Polling |
86 enum TPollMode |
69 enum TPollMode |
87 { |
70 { |
88 EReadyForReading = 1, |
71 EReadyForReading = 1, |
526 const TUint& GetSelectEvents() |
509 const TUint& GetSelectEvents() |
527 { |
510 { |
528 iIoctlLock.Signal(); |
511 iIoctlLock.Signal(); |
529 return iSelectEvents(); |
512 return iSelectEvents(); |
530 } |
513 } |
531 |
514 inline int CreateLock() |
532 inline TInt CreateLock() |
|
533 { |
515 { |
534 TInt err = iIoctlLock.CreateLocal(1) || iReadLock.CreateLocal() || iWriteLock.CreateLocal(); |
516 return (iIoctlLock.CreateLocal(1)|| iReadLock.CreateLocal() || iWriteLock.CreateLocal()); |
535 if (err != KErrNone) |
|
536 { |
|
537 // closes on unopened handles are safe |
|
538 iIoctlLock.Close(); |
|
539 iReadLock.Close(); |
|
540 iWriteLock.Close(); |
|
541 } |
|
542 return err; |
|
543 } |
517 } |
544 |
|
545 inline RSemaphore& GetIoctlLock() |
518 inline RSemaphore& GetIoctlLock() |
546 { |
519 { |
547 return iIoctlLock; |
520 return iIoctlLock; |
548 } |
521 } |
549 inline TBool GetConnectionProgress() |
522 inline TBool GetConnectionProgress() |
556 iConnectInProgress = aInProgress; |
529 iConnectInProgress = aInProgress; |
557 } |
530 } |
558 |
531 |
559 protected: |
532 protected: |
560 //rearrange these |
533 //rearrange these |
561 CSockDescBase():iAddrFamily(-1),iProtocol(KUndefinedProtocol),iIoctlFlag(EFalse),iCount(0) |
534 CSockDescBase():iAddrFamily(-1),iProtocol(KUndefinedProtocol),iIoctlFlag(EFalse) |
562 { |
535 { |
563 |
536 |
564 } |
537 } |
565 RSocket iSocket; |
538 RSocket iSocket; |
566 TSockXfrLength iLength; |
539 TSockXfrLength iLength; |
567 TFileName iPath; |
540 TFileName iPath; |
568 TPckgBuf<TUint> iSelectEvents; |
541 TPckgBuf<TUint> iSelectEvents; |
570 TInt iProtocol; |
543 TInt iProtocol; |
571 TInt iStyle; |
544 TInt iStyle; |
572 // For preventing simultaneous ioctl calls. |
545 // For preventing simultaneous ioctl calls. |
573 // No native support. |
546 // No native support. |
574 RSemaphore iIoctlLock; |
547 RSemaphore iIoctlLock; |
575 // Is this required? |
|
576 TBool iIoctlFlag; |
548 TBool iIoctlFlag; |
577 // Safeguard against issue of a second Read/Write request while the first is pending. |
549 |
578 // The iReadLock also guards OpenUsingPreference |
|
579 //For locking the descriptor before any operation. |
550 //For locking the descriptor before any operation. |
580 //To make it thread safe. |
551 //To make it thread safe. |
581 RFastLock iReadLock; |
552 RFastLock iReadLock; |
582 RFastLock iWriteLock; |
553 RFastLock iWriteLock; |
583 |
554 |
584 //Flag to mark the connect status of a non-blocking socket as "in progress" |
555 //Flag to mark the connect status of a non-blocking socket as "in progress" |
585 //to prevent duplicate connection request |
556 //to prevent duplicate connection request |
586 TBool iConnectInProgress; |
557 TBool iConnectInProgress; |
587 volatile TInt iCount; |
|
588 protected: |
558 protected: |
589 |
559 |
590 inline TInt isStream() const // inline, but private |
560 inline TInt isStream() const // inline, but private |
591 { |
561 { |
592 return iStyle==SOCK_STREAM; |
562 return iStyle==SOCK_STREAM; |
687 void FindConnectionDetailsL(CArrayFixFlat<TAccessPointRecord>*& aRecordPtr, TInt& aCount); |
657 void FindConnectionDetailsL(CArrayFixFlat<TAccessPointRecord>*& aRecordPtr, TInt& aCount); |
688 void FindConnectionInfoL(TAccessPointRecord &aRecord,char *ptr); |
658 void FindConnectionInfoL(TAccessPointRecord &aRecord,char *ptr); |
689 TInt GetInterfaceDetails( void *aParam ,TInt aFlag, TInt aType ); |
659 TInt GetInterfaceDetails( void *aParam ,TInt aFlag, TInt aType ); |
690 TInt SetInterafceParamInfo( void *aParam,TInt aType); |
660 TInt SetInterafceParamInfo( void *aParam,TInt aType); |
691 TInt SetInterfaceDetails( void *aParam ,TInt aFlag, TInt aType ); |
661 TInt SetInterfaceDetails( void *aParam ,TInt aFlag, TInt aType ); |
692 |
|
693 TInt maybe_reopen_socket() |
|
694 { |
|
695 TInt err = KErrNone; |
|
696 if (!__e32_atomic_load_acq32(&iSocketPtr)) |
|
697 { |
|
698 iReadLock.Wait(); |
|
699 if (!iSocketPtr) |
|
700 { |
|
701 err = OpenUsingPreference(); |
|
702 } |
|
703 iReadLock.Signal(); |
|
704 } |
|
705 return err; |
|
706 } |
|
707 |
|
708 enum InterfaceType |
662 enum InterfaceType |
709 { |
663 { |
710 EACCESS_POINT, |
664 EACCESS_POINT, |
711 EACTIVE_CONNECTION, |
665 EACTIVE_CONNECTION, |
712 EACTIVE_GETIP, |
666 EACTIVE_GETIP, |