Flux RSS des billets

DotMG's joblog

Work hard at whatever you do! (Ecc. 9. 10a)
L'archive pour le mois de Octobre 2013 a 2 Billets
Publié le 18 Oct 2013, 3:52 pm dans iseries

I have been coding with RPG/400 for more thant 12 years. These are a number of opcode I've never used, and I even didn't knew exactly what do they mean, and for which purpose may I need to use them.

One of these is FEOD : Force End Of Data.

The FEOD operation signals the logical end of data for a primary, secondary, or full procedural file. The FEOD function differs, depending on the file type and device. (For an explanation of how FEOD differs per file type and device, see the Database Guide, SC41-9659.)

FEOD differs from the CLOSE operation: the program is not disconnected from the device or file; the file can be used again for subsequent file operations without an explicit OPEN operation being specified to the file.

You can specify conditioning indicators. Factor 2 names the file to which FEOD is specified. You can specify a resulting indicator in positions 56 and 57 to be set on if the operation is not completed successfully.

To process any further sequential operations to the file after the FEOD operation (for example, READ or READP), you must reposition the file.

According to its definition, it's like a CLOSE but does not disconnect the program? In fact, this explanation does not say why it may be needed. To understand its use, we must know the mechanism that takes place when you write or read a record in an RPG program.

Physically, the program has 3 resources for storing data : the hard disk : the non-volatile storage device, the RAM buffer, and a DB layer. When you issue the WRITE operation, the record is not necessarily written to disk, it is written to the RAM buffer. Writing to hard disk happens only when the program ends, or when the RAM buffer is full, or when you ask it to be written, by using the FEOD opcode. When you try to access the record with embedded SQL, the program only look at the DB layer, which may be linked to the hard disk, not the RAM buffer. What this means is that, if you write 5 records to your file, then use embedded SQL to access the newly written records, you may not see them.

So, if you mix a SQL opcode WRITE and embedded SQL SELECT in your program, to ensure a correct synchronisation, you must issue an FEOD opcode after each WRITE. This asks the program to write data to disk without waiting for the buffer to be full. It alters performance but this can help you avoid strange results with your application.

Publié le 8 Oct 2013, 6:42 am dans apache

I recently purchased a wildcard SSL for my domain *.dot.mg. I have many subdomains that I wanted also to serve as https.

Once the SSL installed and fully functional, accessing to any of the subdomains leaded to the main site, because SSL configuration is per IP address, and not per domain name. But the solution is very simple, and in 3 lines. It is done by proxying requests to the main site to the non-https version. So, visitor connectes via https to https://blog.dot.mg/, but this request is directed to my main site https://dot.mg/. It will be the responsibility of https://dot.mg/ to redirect internally this request into http://blog.dot.mg/

It is important to know the difference between normal redirection and proxy redirection. With normal redirection, when a visitor goes to https://blog.dot.mg/, he is asked to go to http://blog.dot.mg instead, so he will load the unsecure version of the site. On the other hand, with proxy redirection, it is the webserver who will load the unsecure version of the site, then change all references to http into https and give the modified html page to the visitor. Thus, the communication between the client and the server is secure

 RewriteCond %{HTTP_HOST} ^blog.dot.mg$
 RewriteCond %{HTTPS} =on
 RewriteRule ^(.*)$ http://blog.dot.mg/$1 [P,L]

As simple as that.

The first lines filters the rewriting rule only for the subdomain blog.dot.mg. The second applies only the rule for HTTPS. The third line does the proxy redirection. Note the flag P instead of R. It is the only trick that makes it possible to view the site through https.