Skip to content

Commit

Permalink
Merge branch 'release/v7.2.2' into 'master'
Browse files Browse the repository at this point in the history
Release 7.2.2

See merge request megachat/MEGAchat!2029
  • Loading branch information
MEGA-SDK-releases committed Jan 23, 2025
2 parents 6ddf3a3 + fbaedf8 commit dc049de
Show file tree
Hide file tree
Showing 6 changed files with 404 additions and 126 deletions.
190 changes: 190 additions & 0 deletions jenkinsfile/Jenkinsfile_Release_Management
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
pipeline {
agent { label 'docker' }

options {
buildDiscarder(logRotator(numToKeepStr: '25', daysToKeepStr: '30'))
gitLabConnection('GitLabConnectionJenkins')
}
parameters {
choice(name: 'ACTION', choices: ['Create_Release', 'Create_Release_Candidate', 'Close_Release', 'Patch_Release'], description: 'Pick an action')
string(name: 'SLACK_THREAD_ANNOUNCE', defaultValue: '', description: 'Id of thread root message')
string(name: 'TARGET_APPS', defaultValue: '', description: 'e.g. Android 1.0.1 / iOS 1.2 / MEGAsync 9.9.9 RC1')
string(name: 'RELEASE_VERSION', defaultValue: '', description: 'Optionally define a release version for Create Release. It must exist for Patch Release. Default is 1.0.0.')
string(name: 'TICKETS', defaultValue: '', description: 'Comma separated tickets (patch release or create rc)')
string(name: 'BRANCH_FOR_MR', defaultValue: '', description: 'Branch for MR (create release candidate)')
string(name: 'MR_DESCRIPTION', defaultValue: '', description: 'MR Description (create release candidate)')
password(name: 'GPG_PASSWORD', defaultValue: '', description: 'Enter the password')
booleanParam(name: 'REBUILD_IMAGE', defaultValue: false, description: 'Rebuild docker image. Only needed if the scripts has been modified')
}
environment {
SDK_BRANCH = "develop"
SLACK_TOKEN = credentials('sdk_slack_bot_releases')
GITLAB_TOKEN = credentials('SDK_releases_gitlab_token')
GPG_KEYGRIP = credentials('sdk_gpg_keygrip_release_management')
gpg_key = credentials('sdk_gpg_key_release_management')
GITHUB_TOKEN = credentials('sdk_github_token')
GITHUB_USER = credentials('sdk_github_username')
project_name = "MEGAchat"
slack_channel = "megachat_native"
slack_channel_dev_requests = "sdk_devs_only"
gitlab_url = "${env.GITLAB_BASE_URL}"
jira_url = "${env.JIRA_BASE_URL}"
confluence_url = "${env.CONFLUENCE_BASE_URL}"
confluence_page_id = "3640225"
github_push_remote_url = "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/meganz/MEGAchat.git"
GNUPGHOME = "${WORKSPACE}/.gnupg"
JIRA_TOKEN = credentials('SDK_JIRA_PERSONAL_ACCESS_TOKEN')
CONFLUENCE_TOKEN = credentials('SDK_CONFLUENCE_PERSONAL_ACCESS_TOKEN')
}

stages {
stage('Checkout SDK'){
steps{
dir('third-party/mega'){
checkout([
$class: 'GitSCM',
branches: [[name: "origin/${SDK_BRANCH}"]],
userRemoteConfigs: [[ url: "${env.GIT_URL_SDK}", credentialsId: "12492eb8-0278-4402-98f0-4412abfb65c1" ]],
extensions: [
[$class: "UserIdentity",name: "jenkins", email: "jenkins@jenkins"]
]
])
}
}
}
stage('Replace config file'){
steps {
dir("third-party/mega/automation"){
sh 'cp config.toml.template config.toml'
script {
sh """
sed -i 's|project_name = ""|project_name = "${env.project_name}"|' config.toml
sed -i 's|target_apps = ""|target_apps = "${params.TARGET_APPS}"|' config.toml
sed -i 's|gitlab_url = ""|gitlab_url = "${env.gitlab_url}"|' config.toml
sed -i 's|jira_url = ""|jira_url = "${env.jira_url}"|' config.toml
sed -i 's|slack_channel_dev_requests = ""|slack_channel_dev_requests = "${env.slack_channel_dev_requests}"|' config.toml
sed -i 's|slack_channel_announce = ""|slack_channel_announce = "${env.slack_channel}"|' config.toml
sed -i 's|slack_thread_announce = ""|slack_thread_announce = "${params.SLACK_THREAD_ANNOUNCE}"|' config.toml
sed -i 's|release_version = ""|release_version = "${params.RELEASE_VERSION}"|' config.toml
sed -i 's|github_push_remote_url = ""|github_push_remote_url = "${env.github_push_remote_url}"|' config.toml
sed -i 's|confluence_url = ""|confluence_url = "${env.confluence_url}"|' config.toml
sed -i 's|tickets = ""|tickets = "${params.TICKETS}"|' config.toml
sed -i 's|branch_for_mr = ""|branch_for_mr = "${params.BRANCH_FOR_MR}"|' config.toml
sed -i 's|mr_description = ""|mr_description = "${params.MR_DESCRIPTION}"|' config.toml
"""
}
}
}
}
stage('Build docker image') {
when {
beforeAgent true
expression { return params.REBUILD_IMAGE }
}
steps {
dir ("third-party/mega/dockerfile") {
sh "cp -v ../automation/requirements.txt requirements.txt"
sh """
docker build \
-f release-management.dockerfile \
-t ${env.MEGA_INTERNAL_DOCKER_REGISTRY}:8443/sdk-release-management:latest \
.
"""
}
withCredentials([usernamePassword(credentialsId: 'artifactory-jenkins-docker', usernameVariable: 'ART_USER', passwordVariable: 'ART_PASS')]) {
sh """
echo \$ART_PASS | docker login \
-u \$ART_USER \
--password-stdin \
${env.MEGA_INTERNAL_DOCKER_REGISTRY}:8443
docker push ${env.MEGA_INTERNAL_DOCKER_REGISTRY}:8443/sdk-release-management:latest
"""
}
}
}
stage('Create Release'){
when {
beforeAgent true
expression { params.ACTION == "Create_Release" }
}
agent {
docker {
image "${env.MEGA_INTERNAL_DOCKER_REGISTRY}:8443/sdk-release-management:latest"
reuseNode true
}
}
steps {
dir("automation"){
sh 'gpg --batch --import $gpg_key'
sh 'gpg --list-secret-keys'
sh 'python3 ./make_release.py config.toml'
}
}
}
stage ('Create Release Candidate'){
when {
beforeAgent true
expression { params.ACTION == "Create_Release_CANDIDATE" }
}
agent {
docker {
image "${env.MEGA_INTERNAL_DOCKER_REGISTRY}:8443/sdk-release-management:latest"
reuseNode true
}
}
steps {
dir("automation"){
sh 'gpg --batch --import $gpg_key'
sh 'gpg --list-secret-keys'
sh 'python3 ./make_another_rc.py config.toml'
}
}
}
stage ('Close Release'){
when {
beforeAgent true
expression { params.ACTION == "Close_Release" }
}
agent {
docker {
image "${env.MEGA_INTERNAL_DOCKER_REGISTRY}:8443/sdk-release-management:latest"
reuseNode true
}
}
steps {
dir("automation"){
sh 'gpg --batch --import $gpg_key'
sh 'gpg --list-secret-keys'
sh 'python3 ./close_release.py config.toml'
}
}
}
stage ('Patch Release'){
when {
beforeAgent true
expression { params.ACTION == "Patch_Release" }
}
agent {
docker {
image "${env.MEGA_INTERNAL_DOCKER_REGISTRY}:8443/sdk-release-management:latest"
reuseNode true
}
}
steps {
dir("automation"){
sh 'gpg --batch --import $gpg_key'
sh 'gpg --list-secret-keys'
sh 'python3 ./patch_release.py config.toml'
}
}
}
}
post {
always {
sh "docker rmi ${env.MEGA_INTERNAL_DOCKER_REGISTRY}:8443/sdk-release-management:latest"
deleteDir()
}
}
}

// vim: syntax=groovy tabstop=4 shiftwidth=4
91 changes: 60 additions & 31 deletions src/net/libwebsocketsIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,11 @@ int LibwebsocketsIO::wsGetNoNameErrorCode()
return UV__EAI_NONAME;
}

LibwebsocketsClient::LibwebsocketsClient(WebsocketsIO::Mutex &mutex, WebsocketsClient *client) : WebsocketsClientImpl(mutex, client)
{
wsi = NULL;
}
LibwebsocketsClient::LibwebsocketsClient(WebsocketsIO::Mutex& mutex, WebsocketsClient* client):
WebsocketsClientImpl(mutex, client),
wsi{nullptr},
disconnecting{false}
{}

LibwebsocketsClient::~LibwebsocketsClient()
{
Expand Down Expand Up @@ -279,47 +280,69 @@ void LibwebsocketsClient::wsDisconnect(bool immediate)

void LibwebsocketsClient::doWsDisconnect(bool immediate)
{
if (!wsi)
{
if (!isConnected())
return;
}

if (immediate)
if (disconnecting)
{
struct lws *dwsi = wsi;
wsi = NULL;
lws_set_wsi_user(dwsi, NULL);
WEBSOCKETS_LOG_DEBUG("Pointer detached from libwebsockets");

if (!disconnecting)
if (immediate)
{
lws_callback_on_writable(dwsi);
WEBSOCKETS_LOG_DEBUG("Requesting a forced disconnection to libwebsockets");
removeConnection();
disconnecting = false;
WEBSOCKETS_LOG_DEBUG("Requesting a forced disconnection to libwebsockets while "
"graceful disconnection in progress");
}
else
{
disconnecting = false;
WEBSOCKETS_LOG_DEBUG("Already disconnecting from libwebsockets");
WEBSOCKETS_LOG_WARNING(
"Ignoring graceful disconnect. Already disconnecting gracefully");
}
}
else
{
if (!disconnecting)
const auto lwsContext = lws_get_context(wsi);
markAsDisconnecting();
if (immediate)
{
disconnecting = true;
lws_callback_on_writable(wsi);
WEBSOCKETS_LOG_DEBUG("Requesting a graceful disconnection to libwebsockets");
removeConnection();
WEBSOCKETS_LOG_DEBUG("Requesting a forced disconnection to libwebsockets");
}
else
{
WEBSOCKETS_LOG_WARNING("Ignoring graceful disconnect. Already disconnecting gracefully");
disconnecting = true;
WEBSOCKETS_LOG_DEBUG("Requesting a graceful disconnection to libwebsockets");
}
lws_cancel_service(lwsContext);
}
}

bool LibwebsocketsClient::wsIsConnected()
{
return wsi != NULL;
return isConnected();
}

bool LibwebsocketsClient::isConnected() const
{
return wsi != nullptr;
}

void LibwebsocketsClient::removeConnection()
{
if (!isConnected())
return;
lws_set_wsi_user(std::exchange(wsi, nullptr), NULL);
WEBSOCKETS_LOG_DEBUG("Pointer detached from libwebsockets");
}

std::mutex LibwebsocketsClient::accessDisconnectingWsiMtx{};
std::set<struct lws*> LibwebsocketsClient::disconnectingWsiSet{};

void LibwebsocketsClient::markAsDisconnecting()
{
if (!isConnected())
return;
std::lock_guard g(accessDisconnectingWsiMtx);
disconnectingWsiSet.insert(wsi);
}

const char *LibwebsocketsClient::getOutputBuffer()
Expand Down Expand Up @@ -477,14 +500,25 @@ int LibwebsocketsClient::wsCallback(struct lws *wsi, enum lws_callback_reasons r
break;
}

case LWS_CALLBACK_EVENT_WAIT_CANCELLED:
{
lock_guard g(accessDisconnectingWsiMtx);
while (!disconnectingWsiSet.empty())
{
auto firstEl = disconnectingWsiSet.begin();
lws_callback_on_writable(*firstEl);
disconnectingWsiSet.erase(firstEl);
}
break;
}
case LWS_CALLBACK_CLIENT_CLOSED:
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
{
LibwebsocketsClient* client = (LibwebsocketsClient*)user;
if (!client)
{
WEBSOCKETS_LOG_DEBUG("Forced disconnect completed");
return -1;
break;
}
if (client->disconnecting)
{
Expand All @@ -502,12 +536,7 @@ int LibwebsocketsClient::wsCallback(struct lws *wsi, enum lws_callback_reasons r
WEBSOCKETS_LOG_DEBUG("Diagnostic: %s", buf.c_str());
}

if (client->wsIsConnected())
{
struct lws *dwsi = client->wsi;
client->wsi = NULL;
lws_set_wsi_user(dwsi, NULL);
}
client->removeConnection();
client->wsCloseCb(reason, 0, "closed", 7);
break;
}
Expand Down
Loading

0 comments on commit dc049de

Please sign in to comment.