Skip to content

Commit

Permalink
Fix access to shared resources (#441)
Browse files Browse the repository at this point in the history
fix(network): fix access to shared resources

Serialise access to previously created session configuration objects from different threads.
  • Loading branch information
parfeon authored Dec 14, 2022
1 parent bf69e4e commit e66f0a9
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 207 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/commands-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
process:
name: Process command
if: ${{ github.event.issue.pull_request && endsWith(github.repository, '-private') != true && startsWith(github.event.comment.body, '@client-engineering-bot ') }}
if: ${{ github.event.issue.pull_request && endsWith(github.repository, '-private') != true && startsWith(github.event.comment.body, format('@{0} ', ${{ secrets.CLEN_BOT }})) }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand All @@ -23,4 +23,5 @@ jobs:
uses: ./.github/.release/actions/actions/commands
with:
token: ${{ secrets.GH_TOKEN }}
listener: client-engineering-bot
listener: ${{ secrets.CLEN_BOT }}
jira-api-key: ${{ secrets.JIRA_API_KEY }}
15 changes: 10 additions & 5 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
---
name: objective-c
scm: github.com/pubnub/objective-c
version: "5.1.2"
version: "5.1.3"
schema: 1
changelog:
- date: 2022-12-13
version: v5.1.3
changes:
- type: bug
text: "Serialise access to previously created session configuration objects from different threads."
- date: 2022-12-09
version: v5.1.2
changes:
Expand Down Expand Up @@ -1310,7 +1315,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: PubNub.framework
location: https://github.com/pubnub/objective-c/archive/refs/tags/v5.1.2.zip
location: https://github.com/pubnub/objective-c/archive/refs/tags/v5.1.3.zip
supported-platforms:
supported-operating-systems:
macOS:
Expand Down Expand Up @@ -1371,7 +1376,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: PubNub.ios.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.1.2/PubNub.ios.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.1.3/PubNub.ios.xcframework.tar.gz
supported-platforms:
supported-operating-systems:
iOS:
Expand All @@ -1390,7 +1395,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: PubNub.macos.framework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.1.2/PubNub.macos.framework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.1.3/PubNub.macos.framework.tar.gz
supported-platforms:
supported-operating-systems:
macOS:
Expand All @@ -1406,7 +1411,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: PubNub.tvos.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.1.2/PubNub.tvos.xcframework.tar.gz
location: https://github.com/pubnub/objective-c/releases/download/v5.1.3/PubNub.tvos.xcframework.tar.gz
supported-platforms:
supported-operating-systems:
tvOS:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v5.1.3
December 13 2022

#### Fixed
- Serialise access to previously created session configuration objects from different threads.

## v5.1.2
December 09 2022

Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-iOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-tvOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
6 changes: 3 additions & 3 deletions Framework/PubNub/PubNub-watchOS-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>PubNub</string>
<key>CFBundleGetInfoString</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>CFBundleIdentifier</key>
<string>com.pubnub.pubnub-objc</string>
<key>CFBundleInfoDictionaryVersion</key>
Expand All @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5.1.2</string>
<string>5.1.3</string>
<key>NSHumanReadableCopyright</key>
<string>© 2010 - 2020 PubNub, Inc.</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion PubNub.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Pod::Spec.new do |spec|
spec.name = 'PubNub'
spec.version = '5.1.2'
spec.version = '5.1.3'
spec.summary = 'The PubNub Real-Time Network. Build real-time apps quickly and scale them globally.'
spec.homepage = 'https://github.com/pubnub/objective-c'

Expand Down
15 changes: 15 additions & 0 deletions PubNub/Core/PubNub+Core.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#import "PubNub+CorePrivate.h"
#define PN_CORE_PROTOCOLS PNEventsListener

#include <sys/sysctl.h>
#include <sys/types.h>

#if TARGET_OS_IOS
#import <UIKit/UIKit.h>
#elif TARGET_OS_OSX
Expand Down Expand Up @@ -52,6 +55,18 @@ void pn_safe_property_write(dispatch_queue_t queue, dispatch_block_t block) {
}
}

NSString * pn_cpu_architecture(void) {
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *name = malloc(size);
sysctlbyname("hw.machine", name, &size, NULL, 0);

NSString *architecture = [NSString stringWithCString:name encoding:NSUTF8StringEncoding];
free(name);

return architecture;
}

NSString * pn_operating_system_version(void) {
NSOperatingSystemVersion ver = NSProcessInfo.processInfo.operatingSystemVersion;
NSArray *versionComponents = @[@(ver.majorVersion), @(ver.minorVersion), @(ver.patchVersion)];
Expand Down
128 changes: 54 additions & 74 deletions PubNub/Misc/Categories/NSURLSessionConfiguration+PNConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,123 +3,103 @@

NS_ASSUME_NONNULL_BEGIN

#pragma mark Category interface declaration

/**
@brief \c NSURLSessionConfiguration extension to provide limited \c NSURLSession configuration abilities for
developers.
@author Sergey Mamontov
@since 4.4.0
@copyright © 2010-2018 PubNub, Inc.
* @brief \c NSURLSessionConfiguration extension to provide limited \c NSURLSession configuration abilities for developers.
*
* @author Serhii Mamontov
* @version 5.1.3
* @since 4.4.0
* @copyright © 2010-2022 PubNub, Inc.
*/
@interface NSURLSessionConfiguration (PNConfiguration)


///------------------------------------------------
/// @name Configuration
///------------------------------------------------
#pragma mark - Configuration

/**
@brief Retrieve reference on previously configured set of custom HTTP headers.
@note Dictionary won't include headers provided by \b PubNub client.
@since 4.4.0
@return Previously configured custom set of HTTP headers which should be sent along with every request to
\b PubNub service.
* @brief Retrieve reference on previously configured set of custom HTTP headers.
*
* @note Dictionary won't include headers provided by \b PubNub client.
*
* @return Previously configured custom set of HTTP headers which should be sent along with every request to \b PubNub service.
*/
+ (nullable NSDictionary<NSString *, id> *)pn_HTTPAdditionalHeaders;

/**
@brief Extend additional headers with custom values.
@discussion Additional set of headers which is not used by \b PubNub service but can be used by intermediate
tunneling software.
@note Next set of fields will be ignored: Accept, Accept-Encoding, User-Agent and Connection.
@since 4.4.0
@param HTTPAdditionalHeaders Reference on custom set of HTTP headers which should be sent along with every
request to \b PubNub service.
* @brief Extend additional headers with custom values.
*
* @discussion Additional set of headers which is not used by \b PubNub service but can be used by intermediate
* tunneling software.
*
* @note Next set of fields will be ignored: Accept, Accept-Encoding, User-Agent and Connection.
*
* @param HTTPAdditionalHeaders Reference on custom set of HTTP headers which should be sent along with every request to \b PubNub service.
*/
+ (void)pn_setHTTPAdditionalHeaders:(nullable NSDictionary<NSString *, id> *)HTTPAdditionalHeaders;

/**
@brief Retrieve previously configured configured network service type.
@note \c NSURLNetworkServiceTypeDefault is set by default and will be returned if nothing changed.
@since 4.4.0
@return One of \c NSURLRequestNetworkServiceType enum fields which represent target network service type.
* @brief Retrieve previously configured configured network service type.
*
* @note \c NSURLNetworkServiceTypeDefault is set by default and will be returned if nothing changed.
*
* @return One of \c NSURLRequestNetworkServiceType enum fields which represent target network service type.
*/
+ (NSURLRequestNetworkServiceType)pn_networkServiceType;

/**
@brief Set target network service type.
@since 4.4.0
@param networkServiceType One of \c NSURLRequestNetworkServiceType enum fields which represent target network
service type.
* @brief Set target network service type.
*
* @param networkServiceType One of \c NSURLRequestNetworkServiceType enum fields which represent target network service type.
*/
+ (void)pn_setNetworkServiceType:(NSURLRequestNetworkServiceType)networkServiceType;

/**
@brief Retrieve whether previously has been set to use \c WiFi access \b only or \c cellular can be used as
well.
@since 4.4.0
@return \c YES in case if cellular data can be used as well to access \b PubNub service.
* @brief Retrieve whether previously has been set to use \c WiFi access \b only or \c cellular can be used as well.
*
* @return \c YES in case if cellular data can be used as well to access \b PubNub service.
*/
+ (BOOL)pn_allowsCellularAccess;

/**
@brief Set whether it is allowed to use cellular data to access \b PubNub service or not.
@discussion \b Default: \b YES
@since 4.4.0
@param allowsCellularAccess Whether cellular data usage allowed to get access to \b PubNub service or not.
* @brief Set whether it is allowed to use cellular data to access \b PubNub service or not.
*
* @discussion \b Default: \b YES
*
* @param allowsCellularAccess Whether cellular data usage allowed to get access to \b PubNub service or not.
*/
+ (void)pn_setAllowsCellularAccess:(BOOL)allowsCellularAccess;

/**
@brief Extra set of protocols which will handle requests which is sent to \b PubNub service.
@since 4.4.0
@return Previusly configured requests handling protocol classes.
* @brief Extra set of protocols which will handle requests which is sent to \b PubNub service.
*
* @return Previously configured requests handling protocol classes.
*/
+ (nullable NSArray<Class> *)pn_protocolClasses;

/**
@brief Configure extra set of protocols which will handle requests which is sent to \b PubNub service.
@warning Protocol classes which is prefixed with: \b NS or \b _NS will be ignored.
@since 4.4.0
@param protocolClasses Reference on requests handling protocol classes which should be used with requests to
\b PubNub service.
* @brief Configure extra set of protocols which will handle requests which is sent to \b PubNub service.
*
* @warning Protocol classes which is prefixed with: \b NS or \b _NS will be ignored.
*
* @param protocolClasses Reference on requests handling protocol classes which should be used with requests to \b PubNub service.
*/
+ (void)pn_setProtocolClasses:(nullable NSArray<Class> *)protocolClasses;

/**
@brief Retrieve reference on previously configured connection proxy information.
@since 4.4.0
@return Previously configured connection proxy information which will be used by \c NSURLSession to open and
send requests to \b PubNub service.
* @brief Retrieve reference on previously configured connection proxy information.
*
* @return Previously configured connection proxy information which will be used by \c NSURLSession to open and send requests to \b PubNub service.
*/
+ (nullable NSDictionary<NSString *, id> *)pn_connectionProxyDictionary;

/**
@brief Configure connection proxy.
@discussion This dictionary will be used by \c NSURLSession to open connection to \b PubNub service and send
requests using it.
@since 4.4.0
@param connectionProxyDictionary Dictionary which contain information to setup proxy-based connectino.
* @brief Configure connection proxy.
*
* @discussion This dictionary will be used by \c NSURLSession to open connection to \b PubNub service and send requests using it.
*
* @param connectionProxyDictionary Dictionary which contain information to setup proxy-based connectino.
*/
+ (void)pn_setConnectionProxyDictionary:(nullable NSDictionary<NSString *, id> *)connectionProxyDictionary;

Expand Down
Loading

0 comments on commit e66f0a9

Please sign in to comment.