Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug #4327 mkdir create failed on coroutines #4337

Merged
merged 10 commits into from
Jul 30, 2021
Merged

Fix bug #4327 mkdir create failed on coroutines #4337

merged 10 commits into from
Jul 30, 2021

Conversation

NathanFreeman
Copy link
Member

@NathanFreeman NathanFreeman commented Jul 24, 2021

Fix bug #4327.
One of these coroutines can create top level directory successfully, but other coroutines will fail because the top directory has been created.

So I add this code to solve it. (plain_wrapper.c 1086)

if (p == buf) {
    ret = mkdir(dir, mode);
} else if (!(ret = mkdir(buf, mode)) || EEXIST == errno) {
    if (!p) {
        p = buf;
    }
    /* create any needed directories if the creation of the 1st directory worked */
    while (++p != e) {
        if (*p == '\0') {
            *p = DEFAULT_SLASH;
            if ((*(p + 1) != '\0') && (ret = mkdir(buf, (mode_t) mode)) < 0) {
                // parent directory already exists and try to create child directories.
                if (EEXIST == errno && (int) strlen(buf) < dir_len) {
                    continue;
                }

                if (options & REPORT_ERRORS) {
                    php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
                }
                break;
            }
        }
    }
}

Thanks!

@NathanFreeman NathanFreeman changed the title fix bug #4327 mkdir create failed on coroutines Fix bug #4327 mkdir create failed on coroutines Jul 27, 2021
@matyhtf matyhtf merged commit deeefe3 into swoole:master Jul 30, 2021
@matyhtf
Copy link
Member

matyhtf commented Jul 30, 2021

@NathanFreeman Good job

@mifei077
Copy link

mifei077 commented Aug 2, 2021

@NathanFreeman 您好,我是识沃科技的工作人员,为了感谢您的反馈,请加微信13524075254联系领取我司为您准备的定制小礼物一份,谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants