GenericMappingTools / gmt

The Generic Mapping Tools
https://www.generic-mapping-tools.org
Other
844 stars 353 forks source link

File lock on Windows #3765

Closed seisman closed 4 years ago

seisman commented 4 years ago

A new failure on Windows:

 9/11 Test #815: psxy/urlquakes.sh ................***Failed    4.14 sec
Set GMT_SESSION_NAME = 40326
psxy [ERROR]: Failed to create lock file C:\Users\VSSADM~1\AppData\Local\Temp/query.csv?starttime=2016-01-01%2000:00:00&endtime=2016-02-01%2000:00:00&minmagnitude=4.5&orderby=magnitude.download
psxy [ERROR]: Unable to obtain remote file https://earthquake.usgs.gov/fdsnws/event/1/query.csv?starttime=2016-01-01%2000:00:00&endtime=2016-02-01%2000:00:00&minmagnitude=4.5&orderby=magnitude
ERROR: gmtest:58
memtrack errors: 0
exit status: 1
PaulWessel commented 4 years ago

Fair enough. I need to disable locking on URLs queries.

seisman commented 4 years ago

Closed by #3768.

seisman commented 4 years ago

Re-open the issue because I still see the same error in the recent cron CI job.

joa-quim commented 4 years ago

Still fails for me

psxy [ERROR]: Failed to create lock file C:\TMP/query.csv?starttime=2016-01-01%2000:00:00&endtime=2016-02-01%2000:00:00&minmagnitude=4.5&orderby=magnitude.download

But there are no file locks on Windows, at least like the unix ones, right?

PaulWessel commented 4 years ago

Could you find out why my check for the url query fails? Perhaps that macro has a problem.

joa-quim commented 4 years ago

The problem is not the macro. The error message is not coming from gmtremote_get_url() but from gmt_download_file()

joa-quim commented 4 years ago

Maybe the problem is this. Windows doesn't accept ? in file names (that file was manually created by me).

image

PaulWessel commented 4 years ago

That is fine, it is allowed in the URL and I (think) I am checking the URL string for the question mark. THe idea is that if the URL makes the gmt_M_is_query return true then we dont try to make that lock file, but it is not triggering the test.

joa-quim commented 4 years ago

You are trying to create a file that has question marks in its name

    Lfile = gmtremote_lockfile (API, (char *)name);
    if ((fp = fopen (Lfile, "w")) == NULL) {
        GMT_Report (API, GMT_MSG_ERROR, "Failed to create lock file %s\n", Lfile);
        return 1;
    }

and that is not allowed.

PaulWessel commented 4 years ago

Well, I am trying not to create that file when it is an URL query:

    bool query = gmt_M_file_is_query (url);
    if (!query) {   /* Only make a filename if not a query */
        Lfile = gmtremote_lockfile (API, file);
        if ((fp = fopen (Lfile, "w")) == NULL) {
            GMT_Report (API, GMT_MSG_ERROR, "Failed to create lock file %s\n", Lfile);
            return 1;
        }
        gmtlib_file_lock (GMT, fileno(fp)); /* Attempt exclusive lock */
    }

So clearly query is false for this case and I dont know why.

joa-quim commented 4 years ago

No, query is true. I told you the error message is not coming from that function but from gmt_download_file() where it tries to create a file with a question mark.

PaulWessel commented 4 years ago

Shits, I must have forgotten to duplicate the test there... OK will fix now. Jeez.

joa-quim commented 4 years ago

OK, it works now.

PaulWessel commented 4 years ago

If I don't get it right on the n'th try, I usually get it right on the m'th try (m > n, sometimes m >> n).